//+------------------------------------------------------------------+
//|                                                      b-clock.mq4 |
//|                                     Core time code by Nick Bilak |
//|        Modified by Cobraforex for THV System, www.cobraforex.com | 
//|                                                                  | 
//|        Timecolor now changeable                                  |
//+------------------------------------------------------------------+

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

#property indicator_chart_window


extern color timeColor = White;
extern int sizefont=8;
extern bool show_procent=true;
string l_text_1284 = "-";
string l_text_1296 = "-";
string sh="-";
//---- buffers
double s1[];

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

int init()

  {
   
  }
   return(0);
  
  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

	double i;
   int m,s,k;
   m=Time[0]+Period()*60-CurTime();
   i=m/60.0;
   s=m%60;
   m=(m-m%60)/60;
//   Comment( m + " minutes " + s + " seconds left to bar end");
	
	
   ObjectDelete("time");
   
   if(ObjectFind("time") != 0)
   {
   Orders_Total();
   if (show_procent) sh=l_text_1296;
   else sh=".";
   ObjectCreate("time", OBJ_TEXT, 0, Time[0], Close[0]+ 0.0005);
   ObjectSetText("time","                               "+l_text_1284+" / "+sh, sizefont, "Arial", timeColor);
   }
   else
   {
   ObjectMove("time", 0, Time[0], Close[0]+0.0005);
   }


   return(0);
  }
  void Orders_Total()
{
int i;

for(i=0;i<OrdersTotal();i++)
   {
   if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true)
      {
      if(OrderSymbol()!=Symbol()) continue;
      int points = (MathMax(OrderOpenPrice(),OrderClosePrice())-MathMin(OrderOpenPrice(),OrderClosePrice()))/Point;
      if(OrderProfit()<0) points=0-points;
      l_text_1284 = DoubleToStr(points,0)+ "pips";
      l_text_1296 = DoubleToStr(100.0 * ((OrderProfit() - OrderSwap()) / AccountBalance()), 2) + "%";
      }
   }
}
//+------------------------------------------------------------------+


