We request an authoritative technical clarification of the time semantics used by the official MetaTrader5 Python package. This is a specification question, not account troubleshooting. The requesting environment uses MetaTrader5 Python package 5.0.5735 with MetaTrader 5 terminal build 6140.
Forum on trading, automated trading systems and testing trading strategies
Timezones in Metatrader 5: unclear Python documentation
Anthony Eric Gillon Dawson, 2024.01.31 17:45
Well it seems a bit of a mess... in my case ticks are coming out in proper Unix time UTC while M10, H1 and so on come out with a Unix timestamp shifted by broker time, in my case UTC + 2. As python thinks all Unix stamps are in UTC this causes all sorts of problems in trying to convert them back to UTC particularly if they are also subject to daylight saving! What's the best solution to convert these back to UTC with daylight savings awareness? Or perhaps I should just resample the tick data into M10 & H1 timeframes?
Forum on trading, automated trading systems and testing trading strategies
Timezones in Metatrader 5: unclear Python documentation
Anil Varma, 2025.07.23 13:48
I thought this might be useful information to forum members.
I have used following code to get Brokers time (Check with your broker, which time zone its data represented) and returned by copy_rates_range() or similar methods.
def _downloadData(self, symbol: str, tfEnum: MT5TimeFrame, UTCFrom: datetime, UTCTo: datetime) -> pd.DataFrame: rates = mt5.copy_rates_range(symbol, tfEnum.value, UTCFrom, UTCTo) # <class 'numpy.ndarray'> if rates is None or len(rates) == 0: raise ValueError(f"No data returned from MT5 for {symbol} {tfEnum.name} between {UTCFrom} and {UTCTo}") df = pd.DataFrame(rates) # PepperStone: Cyprus timezone (DST-aware, same as broker/server time) tzPepperStone = pytz.timezone("Europe/Nicosia") # Convert timestamp (MT5 server time) to aware datetime df['DateSVR'] = pd.to_datetime(df['time'], unit='s').dt.tz_localize(tzPepperStone) # Also add UTC and New York time columns for clarity df['DateUTC'] = df['DateSVR'].dt.tz_convert('UTC') df['DateNYC'] = df['DateSVR'].dt.tz_convert('America/New_York') df = df.drop(columns=['time', 'real_volume']) df.set_index('DateNYC', inplace=True) return df
And it has given the correct results
Regards
Thank you for the references.
For this particular case, I need an authoritative MetaQuotes specification or official confirmation for the Python API semantics, especially for history_orders_get() / history_deals_get(), the returned ORDER_TIME_* / DEAL_TIME fields, and the date_to boundary.
Do you know of any official MetaQuotes documentation or statement that defines these semantics explicitly?
Thank you for the references.
For this particular case, I need an authoritative MetaQuotes specification or official confirmation for the Python API semantics, especially for history_orders_get() / history_deals_get(), the returned ORDER_TIME_* / DEAL_TIME fields, and the date_to boundary.
Do you know of any official MetaQuotes documentation or statement that defines these semantics explicitly?
https://www.mql5.com/en/docs/python_metatrader5/mt5historyordersget_py
https://www.mql5.com/en/docs/python_metatrader5/mt5historydealsget_py
Forum on trading, automated trading systems and testing trading strategies
Are history_orders_get() and history_deals_get() always chronologically ordered in MQL5?
fxsaber, 2023.09.13 14:58
Forum on trading, automated trading systems and testing trading strategies
Are history_orders_get() and history_deals_get() always chronologically ordered in MQL5?
fxsaber, 2023.09.13 17:10
Unfortunately, orders are not added in chronological order. You can delete an order, but it will not necessarily be at the end of the trading history.
The terminal developers are aware of this behavior and are not going to change it.
https://www.mql5.com/en/docs/python_metatrader5/mt5historyordersget_py
https://www.mql5.com/en/docs/python_metatrader5/mt5historydealsget_py
Thank you.
I have reviewed both official MetaQuotes pages you linked. They document the functions and parameters, but I cannot find an explicit statement there defining:
- the timezone/time reference of date_from and date_to,
- the timezone/time reference of ORDER_TIME_SETUP, ORDER_TIME_DONE, DEAL_TIME and the *_MSC fields,
- or whether date_to is inclusive or exclusive.
Do you know of any official MetaQuotes documentation or statement that explicitly defines those points?
Thank you.
All of these share one basis: the trade server's time, not UTC and not local/OS time. The MT5 datetime is formed on the server and is independent of the computer clock, and the Python package returns those same epoch integers unchanged.
Thank you, this is very helpful.
Could you please point me to an official MetaQuotes documentation page or official MetaQuotes statement that explicitly confirms that history_orders_get() / history_deals_get() use trading-server time for date_from , date_to , ORDER_TIME_SETUP , ORDER_TIME_DONE , DEAL_TIME and the corresponding *_MSC fields?
Also, do you know whether date_to is inclusive or exclusive, and at what precision?
Finally, when you say the Python package returns the same epoch integers unchanged, do you mean true Unix/UTC epoch timestamps, or server-wall-clock values encoded as epoch seconds?
Thank you.
Forum on trading, automated trading systems and testing trading strategies
MetaQuotes-Demo: matching M1/H1 gaps at 23:00 and 00:00 on XAUAUD/XPTUSD, 15–17 Sep 2026
Alain Verleyen, 2026.09.22 17:38
The problem is the documentation is wrong. The data returned from MT5 has the broker server time zone, not UTC.Thank you, this is very important.
To make sure I understand correctly, does your statement also apply specifically to history_orders_get() and history_deals_get() , including date_from , date_to , ORDER_TIME_SETUP , ORDER_TIME_DONE , DEAL_TIME and the corresponding *_MSC fields?
Also, do you know whether date_to is inclusive or exclusive, and at what precision?
Finally, since you reported the datetime/timezone documentation issue to MetaQuotes, is there any official MetaQuotes ticket, updated documentation page, or confirmation that can be cited?
Thank you.
Thank you, this is very important.
To make sure I understand correctly, does your statement also apply specifically to history_orders_get() and history_deals_get() , including date_from , date_to , ORDER_TIME_SETUP , ORDER_TIME_DONE , DEAL_TIME and the corresponding *_MSC fields?
Also, do you know whether date_to is inclusive or exclusive, and at what precision?
Finally, since you reported the datetime/timezone documentation issue to MetaQuotes, is there any official MetaQuotes ticket, updated documentation page, or confirmation that can be cited?
Thank you.
The same applies to the whole API.
You need to use UTC timezone in your parameters, and the returned data are broker server time.
The same applies to the whole API.
You need to use UTC timezone in your parameters, and the returned data are broker server time.
Thank you, that clarifies the most important distinction.
Just two remaining points for audit purposes:
- Is date_to inclusive or exclusive for history_orders_get() and history_deals_get() , and at what precision?
- Is there any official MetaQuotes ticket, documentation update, or statement that can be cited for the UTC-input / broker-server-time-output behavior?
Thank you.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear MetaQuotes Technical Support,
We request an authoritative technical clarification of the time semantics used by the official MetaTrader5 Python package. This is a specification question, not account troubleshooting. The requesting environment uses MetaTrader5 Python package 5.0.5735 with MetaTrader 5 terminal build 6140.
Please answer each question separately:
For audit purposes, please state explicitly when a question is outside MetaQuotes’ authority or requires confirmation from the broker.
Thank you.