Can MQL5 uniquely determine the UTC open time of historical CopyRates bars?

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.

  1. 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?

  2. Is there any official MQL5 API or historical metadata that provides the broker's UTC offset applicable when a particular historical bar opened?

  3. 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?

  4. 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?

  5. 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.

Documentation on MQL5: CopyRates / Timeseries and Indicators Access
Documentation on MQL5: CopyRates / Timeseries and Indicators Access
  • www.mql5.com
Gets history data of MqlRates structure of a specified symbol-period in specified quantity into the rates_array array. The elements ordering of the...
Alain Verleyen #:

Ask your AI to search for answers before posting.


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:

  1. What exact UTC offset, in seconds, applies to the MetaQuotes-Demo timestamp labels for a specified historical interval?
  2. What exact effective start/end times define that interval, including any seasonal offset changes?
  3. 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.

STAR1A #:

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:

  1. What exact UTC offset, in seconds, applies to the MetaQuotes-Demo timestamp labels for a specified historical interval?
  2. What exact effective start/end times define that interval, including any seasonal offset changes?
  3. 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.

STAR1A #:
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:

Code Base

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.

Ryan L Johnson #:

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.