Forum on trading, automated trading systems and testing trading strategies
MetaTrader5 Python API timestamp semantics: UTC or broker server time?
Sergey Golubev, 2026.09.30 08:50
It was already discussed many times, for example:
Ask your AI to search for answers before posting.
Forum on trading, automated trading systems and testing trading strategies
MetaTrader 5 build 6231: clock basis of historical Symbols → Ticks timestamps and exported CSV
Alain Verleyen, 2026.10.08 16:00
ALL data MT5 returns are ALWAYS broker server time data.Thank you very much, Sergey and Alain, for taking the time to respond.
Sergey, I appreciate you sharing the related discussions and references. I will read through them carefully.
Alain, thank you for clarifying that MT5 returns broker server time data. This is very helpful for understanding the timestamp behavior.
I sincerely appreciate both of your help and guidance.
Best regards.
Thank you. I have read this thread and the linked discussions.
I understand that MT5 returned historical data should be treated as broker/trade-server time rather than UTC.
For MetaQuotes-Demo specifically, I still cannot find an authoritative answer to three points needed for deterministic historical conversion:
- What exact UTC offset, in seconds, applies to the MetaQuotes-Demo timestamp labels for a specified historical interval?
- What exact effective start/end times define that interval, including any seasonal offset changes?
- Are historical bar/tick timestamp labels preserved as originally stored, or can they be re-converted/rebuilt under a later server-time configuration?
If there is an official MetaQuotes statement, configuration reference, or documented source for these three points, could you please point me to it?
Thank you.
Thank you. I have read this thread and the linked discussions.
I understand that MT5 returned historical data should be treated as broker/trade-server time rather than UTC.
For MetaQuotes-Demo specifically, I still cannot find an authoritative answer to three points needed for deterministic historical conversion:
- What exact UTC offset, in seconds, applies to the MetaQuotes-Demo timestamp labels for a specified historical interval?
- What exact effective start/end times define that interval, including any seasonal offset changes?
- Are historical bar/tick timestamp labels preserved as originally stored, or can they be re-converted/rebuilt under a later server-time configuration?
If there is an official MetaQuotes statement, configuration reference, or documented source for these three points, could you please point me to it?
Thank you.
1. It's your job to calculate it, there is no direct function giving you this offset.
3. That's a question for the broker or it required monitoring and investigation, to my knowledge such inquiry has not be done.
If there is an official MetaQuotes statement, configuration reference, or documented source for these three points, could you please point me to it?
GMT is the standard time against which all other times are compared for conversion purposes. The overwhelming majority of MT5 utilities are custom utilities for which there is no "official Metaquotes documentation." If you're willing to accept such a custom utility, see:
TimeGMT library for the strategy tester
amrali, 2024.02.22 01:54
Static class to fix the TimeGMT() function during testing in the strategy tester.GMT is the standard time against which all other times are compared for conversion purposes. The overwhelming majority of MT5 utilities are custom utilities for which there is no "official Metaquotes documentation." If you're willing to accept such a custom utility, see:
Thank you both, Alain and Ryan, for your helpful replies.
I appreciate the clarification and the library reference.
Your responses have helped me better understand the limitations and what still needs to be verified.
Thank you again for your time and assistance.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Subject: Can MQL5 uniquely determine the UTC open time of historical CopyRates bars?
I would like to clarify the technical guarantees of MetaTrader 5 regarding historical bar timestamps.
This is a question about MQL5 API behavior, not trading strategy or a specific broker's DST policy.
Suppose a broker uses UTC+2 in winter and UTC+3 in summer.
Does MqlRates.time, returned by CopyRates(), represent the broker's server-time bar opening label, or is it guaranteed to represent an absolute UTC instant?
Is there any official MQL5 API or historical metadata that provides the broker's UTC offset applicable when a particular historical bar opened?
If the broker's server clock moves backward at the end of DST and bars exist during the repeated hour, how does MT5 represent and distinguish those bars?
After a terminal restart or historical data download, can the UTC opening time of each historical bar be uniquely reconstructed using only standard MQL5 APIs?
Are these behaviors documented or guaranteed by MetaQuotes? If so, could you provide the relevant official documentation?
I understand that DST transitions often occur while the Forex market is closed. However, I am specifically asking about the guarantees of the platform and its historical timestamp representation, rather than assuming that no bars exist during a transition.
References:
https://www.mql5.com/en/docs/series/copyrates
https://www.mql5.com/en/docs/constants/structures/mqlrates
https://www.mql5.com/en/docs/dateandtime
Thank you for any technical clarification or authoritative references.