Download MetaTrader 5

Indicators: Zero Lag Timer

To add comments, please log in or register
Automated-Trading
Admin
107792
Automated-Trading  

Zero Lag Timer:

Implementation of Zero Lag Countdown Timer.

Zero Lag Timer (Well Sort Of)

Author: William Kreider

Alonedevils
38
Alonedevils  
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
5479
file45  

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));
   if(ObjectFind(thisChart,"BarTimer")>=0){

Modified Code 

void OnTimer()
  {
//---
   //datetime localtime;
   localtime = TimeLocal()+(TimeGMTOffset()+((60*60)*2));
   if(ObjectFind(thisChart,"BarTimer")>=0){

 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
3378
Ex Ovo Omnia  
I like the clock that looks like the Windows system clock.
Alain Verleyen
Moderator
33605
Alain Verleyen  
Ovo:
I like the clock that looks like the Windows system clock.
It's the Windows system clock(s)
file45
5479
file45  

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
5479
file45  

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
16295
whroeder1  
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;
   ObjectSetText(TIMER,
      TimeToStr(Time[0] + PeriodSeconds() - servertime, TIME_SECONDS),
      textSize, sFontType, fntcolor);
}
Simplified code attached.
Files:
whroeder1
16295
whroeder1  
Update to display days-hms (for week/monthly charts)
Files:
Mohammad Hossein Sadeghi
2076
Mohammad Hossein Sadeghi  

For MQL5 version, developers can use

TimeTradeServer()

instead, it was very good to have it in MQL4 also :)

I started a poll for required functions regarding Date and Time: TimeTradeServerGMTOffset() and/or GetTradeServerTimeZoneInfo()https://www.mql5.com/en/forum/217145

MQL4/5 required functions: TimeTradeServerGMTOffset() or GetTradeServerTimeZoneInfo()
MQL4/5 required functions: TimeTradeServerGMTOffset() or GetTradeServerTimeZoneInfo()
  • 2017.10.10
  • www.mql5.com
Expert Advisors and Automated Trading: MQL4/5 required functions: TimeTradeServerGMTOffset() or GetTradeServerTimeZoneInfo()
To add comments, please log in or register