You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Forum on trading, automated trading systems and testing trading strategies
Authoritative MetaQuotes-Demo tick timestamp and copy_ticks_range time-domain semantics
Alain Verleyen, 2026.09.24 17:35
I reported the documentation issue about datetime and timezone to MetaQuotes.
Where is the documentation wrong ? Each time it claims the following :
The confusion comes from how Python datetime is working, by default it will use the local timezone, the one of the computer where the python code is running, so to avoid returning different data depending where your code run, it's requested to set UTC timezone for each datetime parameter used in a python/MQL5 functions. So you need to use an UTC timezone datetime to finally receive data using the broker server timezone including DST.
An example to illustrate this :
2026.09.24 13:27:39.878 Display obtained 'UTC TZ' data 'as is'
2026.09.24 13:27:39.878 (1736467200, 1.03011, 1.03011, 1.0294, 1.02998, 288, 4, 0)
2026.09.24 13:27:39.878
2026.09.24 13:27:39.878 Display dataframe with date_from using UTC
2026.09.24 13:27:39.878 time open high low close tick_volume spread real_volume
2026.09.24 13:27:39.878 0 2025-01-10 1.03011 1.03011 1.0294 1.02998 288 4 0
2026.09.24 13:27:39.878 Display obtained 'local TZ' data 'as is'
2026.09.24 13:27:39.878 [(1736485200, 1.03016, 1.03031, 1.02975, 1.02983, 698, 0, 0)]
2026.09.24 13:27:39.878
2026.09.24 13:27:39.878 Display dataframe with date_from using local time (no TZ specified)
2026.09.24 13:27:39.878 time open high low close tick_volume spread real_volume
2026.09.24 13:27:39.878 0 2025-01-10 05:00:00 1.03016 1.03031 1.02975 1.02983 698 0 0
2025.10.01 00:00 is 1736467200 (epoch time in seconds)
2025.10.01 05:00 is 1736485200 with my local timezone shift at that date. If you run this code from a different timezone, the first one will be the same, but the second one will differ.
So you get different data because you request different datetime, python/MQL5 API request UTC datetime. But the data MT5 returns are ALWAYS broker server time data.