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