Download MetaTrader 5

Indicators: Zero Lag Timer

To add comments, please log in or register
Looking for like-minded people? You will find lots of them on the Forum!
Automated-Trading 2014.07.30 11:58 

Zero Lag Timer:

Implementation of Zero Lag Countdown Timer.

Zero Lag Timer (Well Sort Of)

Author: William Kreider

Alonedevils 2014.10.07 20:48  
Thanks For Indicator ..
Working Great ..
But There Is Any Option To Disabling Hour Count Down ?
I Mean How To Use This Indicator For Just Minutes and Second Countdown ..

Thanks :)
file45 2014.10.14 02:34  

A great piece of coding and the only countdown timer I have seen that does a properly job by virtue of continuous countdown.

However, some problems exist:

  • The above image shows USDCHF, H1 with a remaining time of 01:19:20. This is obviously incorrect. The remaing time should be 00:19:20.

As many will find this countdown indicator far better than the non-continuous variety I have had a shot at correcting the above and hope it causes no offence and also stands the test of time. 

Original Code

void OnTimer()
   //datetime localtime;
   localtime = TimeLocal()+(TimeGMTOffset()+(60*60));

Modified Code 

void OnTimer()
   //datetime localtime;
   localtime = TimeLocal()+(TimeGMTOffset()+((60*60)*2));

 Got to discussion for file

H1 Candle


H4 Candle

Note: Broker time is one hour ahead of local time so the H4 candle will close at 23:00:00. The candle opened at 19:00:00. 


M1 Candle 


Ex Ovo Omnia
Ex Ovo Omnia 2014.10.14 15:24  
I like the clock that looks like the Windows system clock.
Alain Verleyen
Alain Verleyen 2014.10.14 16:04  
I like the clock that looks like the Windows system clock.
It's the Windows system clock(s)
file45 2014.10.18 14:47  

Clocks used to measure indicator precision. Results may vary depending equipment.

H1 Candles:

08 + 52 seconds = 60 seconds = 1 minute → add 1 minute to total minutes.

33 + 26 seconds = 59 minutes + 1 minute = 60 minutes = 1 hour → add 1 hours to total hours.

00 + 20 = 20 hour + 1 hour = 21:00:00.

M1 Candle:

00:00:19 + 13:22:41 = 13:23:00.

file45 2014.10.30 03:07  

The above fix applies only to British Summer Time and same time locations.

The below fix accommodates summer/ winter time clock adjustments and GMT offset and should solve for all locations.

See Inputs tab - Broker Time adjustment - for GMT offset. Set - Broker Time adjustment - Value to x hours ahead of GMT. If Broker Time = GMT set - Broker Time adjustment - Value to 0 (zero).


Have tested on separate MT4 Terminals with Broker Times at GMT, GMT+1 and GMT+3. 

xzl Countdown Timer fix a2 - does not include new bar/candle alert.

xzl Countdown Timer fix b2 - includes new bar/candle alert. 

whroeder1 2016.09.23 16:28  
All this discussion of GMT offset, timezones etc are unnecessary. All you need is local time and server time. Period.
double   round_nearest( double v, double to){   return to * MathRound(v / to); }
int               localToServer;
int OnInit(){ ... localToServer = (int)round_nearest(TimeCurrent() - TimeLocal(), 1800); ...}
void OnTimer(){
   datetime servertime  = TimeLocal() + localToServer;
      TimeToStr(Time[0] + PeriodSeconds() - servertime, TIME_SECONDS),
      textSize, sFontType, fntcolor);
Simplified code attached.
To add comments, please log in or register