Please search before you post ...
Forum on trading, automated trading systems and testing trading strategies
Is there a way to know the Broker's Timezone using the Python API for MT5?
Fernando Carreiro, 2023.10.20 21:22
I was under the impression that the Python API offered functions equivalent to MQL5's TimeCurrent and TimeTradeServer, but it seems it does not.
I'm not a Python programmer, so I don't know if there are other workarounds to the issue, but the only thing I can think of at the moment, is to wait for an incomming tick, and then calculate the time difference, using the tick's timestamp and comparing it to the current UTC time.
Forum on trading, automated trading systems and testing trading strategies
Is there a way to know the Broker's Timezone using the Python API for MT5?
Fernando Carreiro, 2023.10.20 21:26
Another option is to monitor the "time" from symbol_info and when it changes, compre it to the UTC for calculating the difference.
This is somewhat similar to the tick timestamp example in the previous post.
Forum on trading, automated trading systems and testing trading strategies
Is there a way to know the Broker's Timezone using the Python API for MT5?
Alain Verleyen, 2023.10.21 03:14
You know your local time.
You know your local timezone, so GMT shift, it's easy to get it with Python.
When you get live ticks data, you get the "live" server time, like Fernando suggested.
From these information it's trivial to calculate the broker server time shift related to GMT. All of that can be done by code, there is no need to hardcode anything.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Using python with mt5
https://www.mql5.com/en/docs/python_metatrader5/mt5login_py
How can I get the broker's server datetime?