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

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

#property indicator_chart_window
extern color  ClockColor = CadetBlue;
extern int    shift        =  9;
extern bool   Bid_Ask_Colors = True;
extern color  FontColor = CadetBlue;
extern int    shiftt       =  9;
//---- buffers

int n_digits = 0;
double divider = 1;
double Old_Price;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
  
   return(0);
}
int deinit()
{
   ObjectDelete("time");
   ObjectDelete("Spread");
   ObjectDelete("Market_Price_Label"); 
   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
 RefreshRates();
   
   double spread = (Ask - Bid) / Point/10;
   ObjectSetText("Spread", "Spread: " + DoubleToStr(NormalizeDouble(spread*10 / divider, 1), n_digits) + " points.", shift, ClockColor);
	double i;
   int m,s;
   m=Time[0]+Period()*60-CurTime();
   i=m/60.0;
   s=m%60;
   m=(m-m%60)/60;
   if (Bid_Ask_Colors == True)
   {
    if (Bid > Old_Price) FontColor = LawnGreen;
    if (Bid < Old_Price) FontColor = OrangeRed;
    Old_Price = Bid;
   }
   
   string Market_Price = DoubleToStr(Bid, Digits);
	
   ObjectDelete("time");
   
   if(ObjectFind("time") != 0)
   {
   ObjectCreate("time", OBJ_TEXT, 0, Time[0], Close[0]- 0.0000);
   ObjectSetText("time","                                              <<--"+m+":"+s+" || " + spread  ,  shift, "Verdana", ClockColor);
   ObjectDelete("time1");
   if(ObjectFind("time1") != 0)
   {
   ObjectCreate("time1", OBJ_TEXT, 0, Time[0], Close[0]- 0.00011);
   ObjectSetText("time1","                                                      ("+ Market_Price+")"  , shiftt, "Verdana", FontColor);                                            
   }
   }
   else
   {
    ObjectMove("time", 0, Time[0], Close[0]+0.0003);
    ObjectMove("time1", 0, Time[0], Close[0]+0.0004);
   }
  
   return(0);
  }
//+------------------------------------------------------------------+


