EA Time Trouble

 
Is matching the EA time with the broker’s time one of the biggest challenges?
 
Eusebiu Dascalu:
Is matching the EA time with the broker’s time one of the biggest challenges?

Not really.

iTime(...) returns the open time of any bar that you select.

Then you have the "realtimes" of TimeCurrent(), TimeLocal() TimeGMT(), and TimeTradeServer().

Basically, you can call whichever time you like─outside of the Tester, that is.

 
Eusebiu Dascalu:
Is matching the EA time with the broker’s time one of the biggest challenges?
Well, that depends: 
if the EA uses some sort of time logic then you must match the broker time or adjust offset. This is critical.
If it's not then don’t overthink it. It's not that important in that case.
 

I use a function to detect the brokers time offset from GMT, and then I convert the time to GMT. This way for time inputs - it will always be GMT, and things are consistent.

It's important to detect timezone offsets rather than use a static timezone, because the broker can change the timezone when the US switches between standard time and daylight saving time. In winter months the timezone is different than in summer months.

 

Recent development: You can now control your chart time zone by way of a custom chart service.

Forum on trading, automated trading systems and testing trading strategies

How to change time zone in MT5?

Ryan L Johnson, 2026.05.09 16:44

Lo and behold, Aleksandr Slavskii coded an improved version of his Period Converter Mod service plainly named, Period Converter (attached below), that generates a time-offset custom chart (in addition to supporting creation of custom timeframes not natively supported in MT5). Aleksandr Slavskii kindly did so at my request. Although I'm not in the habit of posting unpublished source code of other developers, Aleksandr Slavskii expressly allowed me to do so. This work of his will finally put an end to decades of MT5 traders searching for a time zone fix.

The input, "Time shift in minutes", is exactly that. Regardless of the timeframe that you select, the timestamps of the generated bars are shifted by minutes. Therefore, use 60 for each hour of shift (offset). That input supports both positive or negative shift values, so no one on Earth is left out.

Please respect the copyright that is included in the code─as a matter of international law. Aleksandr Slavskii reserves all rights.