# OTCFX_b-clock modified V4-sw





//+------------------------------------------------------------------+
//|                                            #OTCFX  b-clock_SW.mq4  |
//|                                     Core time code by Nick Bilak |
//|        http://metatrader.50webs.com/         beluck[at]gmail.com |
//|                                  modified by adoleh2000 and dwt5 |
//|                                 Modified and improved by "OTCFX"                                          | 
//|
//| |                                                                |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2005, Nick Bilak"
#property link      "http://metatrader.50webs.com/"

#property indicator_separate_window
#property indicator_color1 Aqua

extern color  BClockClr =  Aqua;
extern color  ClksColor =  Lime;
extern color SameTFColor = Red;
extern color  TDCOL =  Aqua;
extern bool   show.Bclk = true ;
extern string myFont         = "Arial Bold" ;
extern string myFont2        = "Verdana Bold" ;
extern bool show.M1 = true ;
extern bool show.M5 = true ;
extern bool show.M15 = true ;
extern bool show.M30 = true ;
extern bool show.H1 = true ;
extern bool show.H4 = true ;
extern bool show.D1 = true ;
int   TimeFrame    = 0 ;
int FontSz = 16;

string version = "B-ClockV4";
string prefix = "CLKV4";
int Win;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

double s1[];

int init()
{
   IndicatorShortName(prefix); 

   switch(TimeFrame)
   {
      case 1  : string TimeFrameStr="M1" ;   break;    
      case 5  :     TimeFrameStr=   "M5" ;   break;
      case 15 :     TimeFrameStr=   "M15";   break;     
      case 30 :     TimeFrameStr=   "M30";   break;
      case 60 :     TimeFrameStr=   "H1" ;   break;
      case 240  :   TimeFrameStr=   "H4" ;   break;
      case 1440 :   TimeFrameStr=   "D1" ;   break;
      case 10080 :  TimeFrameStr=   "W1" ;   break;
      case 43200 :  TimeFrameStr=   "MN1";   break;
      default  :    TimeFrameStr=   "CurrTF";
    }   
   return(0);  
}

   
int deinit()
  {
  int total = ObjectsTotal();  
  for (int i=total-1; i >= 0; i--) 
  {
    string name = ObjectName(i);
    if (StringFind(name, prefix) == 0) ObjectDelete(name);
  }
  Comment("");
  return(0);
}
  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
 
   Win = WindowFind(prefix);
   if (Win == -1) Win = 0;
  
   if (TimeFrame==0) TimeFrame=Period();
   int yPos = 24, xPos = 10;
   int xSpacer = 140;

	double i;
   int m,s,k,h;  
 
   for(i = 1; i <= 10; i++) 
   {
      switch(i)
      {
         case 1: if(show.M1)  CreateLabel(prefix + "clock" + i, PERIOD_M1, "",  FontSz, myFont, ClksColor, 0, xPos, yPos); break;
         case 2: if(show.M5)  CreateLabel(prefix + "clock" + i, PERIOD_M5, "", FontSz, myFont, ClksColor, 0, xPos, yPos); break;
         case 3: if(show.M15) CreateLabel(prefix + "clock" + i, PERIOD_M15, "", FontSz, myFont, ClksColor, 0, xPos, yPos); break;
         case 4: if(show.M30) CreateLabel(prefix + "clock" + i, PERIOD_M30, "", FontSz, myFont, ClksColor, 0, xPos, yPos); break;
         case 5: if(show.H1)  CreateLabel(prefix + "clock" + i, PERIOD_H1, "", FontSz, myFont, ClksColor, 0, xPos, yPos); break;
         case 6: if(show.H4)  CreateLabel(prefix + "clock" + i, PERIOD_H4, "", FontSz, myFont, ClksColor, 0, xPos, yPos); break;
         case 7: if(show.D1)  CreateLabel(prefix + "clock" + i, PERIOD_D1, "", FontSz, myFont, ClksColor, 0, xPos, yPos); break;

         case 8:  CreateLabel(prefix + "clock" + i, -1, TimeToStr(CurTime(),TIME_SECONDS), 11, "Verdana Bold", TDCOL, 0, 250, 5); break;
         case 9:  CreateLabel(prefix + "clock" + i, -1, TimeToStr(CurTime(),TIME_DATE), 10, "Verdana", TDCOL, 0, 155, 5); break;
         case 10: CreateLabel(prefix + "clock" + i, -1, version, 13, "Verdana Bold", Orchid, 0, 45, 1); break;
       }
       xPos = xPos+xSpacer;     
   }
   
   m=iTime(NULL,TimeFrame,0)+TimeFrame*60 - TimeCurrent();
   i=m/60.0;
   s=m%60;
   m=(m-m%60)/60;
   h=m/60;
   string Bclk=   "                   <"+m+":"+s; 
   
   if(show.Bclk) {Comment( m + " minutes " + s + " seconds left to bar end");}
      
   ObjectDelete(prefix + "time");  
   if(ObjectFind(prefix + "time") != 0)
   {
      if(show.Bclk ) ObjectCreate(prefix + "time", OBJ_TEXT, 0, Time[0], Close[0]+ 0.0000);
      if(show.Bclk ) ObjectSetText(prefix + "time",Bclk, 10, "Verdana Bold" ,BClockClr);
   }
   else
      ObjectMove(prefix + "time", 0, Time[0], Close[0]+0.0005);
  

   return(0);
  }
//+------------------------------------------------------------------+

void CreateLabel(string LblName, int TFrame, string text, double FontSz, string FontName, color FontColor, int Corner, int xPos, int yPos)
{
	double i;
   int m,s,k,h; 
   string LabelTxt; 
   color FColor;

   //If we aren't creating a TFrame Clock then text for Label has been passed to this function
   LabelTxt = text;
   //If Tframe > -1 then we are creating a clock label
   if (TFrame > -1)
   {
      m=iTime(NULL,TFrame,0)+TFrame*60 - CurTime();
   
      i=m/60.0;
      s=m%60;
      m=(m-m%60)/60;
      h=m/60;
 
      LabelTxt =  "|" + TF2Str(TFrame) + "| "+m+"m:"+s; 
   }

   FColor = FontColor;
   if(Period()==TFrame) FColor = SameTFColor;
   
   if(ObjectFind(LblName) != 0) ObjectCreate(LblName, OBJ_LABEL, Win, 0, 0);

   ObjectSetText(LblName, LabelTxt, FontSz, FontName, FColor);
   ObjectSet(LblName, OBJPROP_CORNER, Corner);
   ObjectSet(LblName, OBJPROP_XDISTANCE, xPos);
   ObjectSet(LblName, OBJPROP_YDISTANCE, yPos); 
}

string TF2Str(int period) 
{
  switch (period) 
  {
    case PERIOD_M1: return("M1");
    case PERIOD_M5: return("M5");
    case PERIOD_M15: return("M15");
    case PERIOD_M30: return("M30");
    case PERIOD_H1: return("H1");
    case PERIOD_H4: return("H4");
    case PERIOD_D1: return("D1");
    case PERIOD_W1: return("W1");
    case PERIOD_MN1: return("MN");
  }
  return (Period());
} 



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar
Series array that contains open time of each bar


Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: