Time to CS close.

 
Doses anybody knows if it's possible to display time (countdown) when current CS will be closed? Maybe a script or something like that... It would be useful rather than calculating manually...

Thanks.
 
CS = what?
 

CS = what?


Oh, sorry, CS=CandleStick :-)
 
Try this:

int m,s,k,h;
m=Time[0]+Period()*60-TimeCurrent();
s=m%60;
m=(m-m%60)/60;
if(m>=60) h=m/60; else h=0;
k=m-(h*60);

Comment( h,"  hours  ",k,"  minutes  ",s,"  seconds left to end of bar");
 
Thenks a lot Wackena! Works really great.
Just additional question there is no way to make this countdown automatic? So there is no need to execute script each time to see a progress? Or maybe MT4 has an option of executing scripts every minute or something?

Thenks once again!
 
Put the code in an indicator


Create new indicator

..
..

start()
{
... insert code

return(0);
}
 
Put the code in an indicator


Create new indicator

..
..

start()
{
... insert code

return(0);
}




Hmm, it looks that I did everything as suggested but no effect.... still no automatic countdown... any idea why?
 
Try this:

//+------------------------------------------------------------------+
//|                                                    Bar Clock.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    double g;
   int m,s,k,h;
   m=Time[0]+Period()*60-TimeCurrent();
   g=m/60.0;
   s=m%60;
   m=(m-m%60)/60;
//   Comment( m + " minutes " + s + " seconds left to bar end");
   if(m>=60) h=m/60; else h=0;
   k=m-(h*60);
   Comment(h," hours ",k," minutes ",s," seconds left to bar end");
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
Reason: