I'm trying to copy the last X ticks from a given currency, but am left with sporadic results.
for currency in currency_pairs:
server_time = mt5.symbol_info_tick(currency).time
ticks = mt5.copy_ticks_from(currency, server_time, 50, mtmain.COPY_TICKS_INFO)
logging.info(f"{currency} {ticks}\n")
Here I should be retrieving the last 50 ticks starting from the current server time. It partially works; the following output shows the correct tick (bid and ask), as they line up with what I see in MetaTrader. The problem is the number of ticks varies - sometimes only a single tick, other times 4, or 9, etc. instead of 50.
If I retrieve the last 50 ticks not from server time, but from local time (2h behind), then I get 50 ticks every time.
Another weird thing is that the server time retrieved from the last tick (mt5.symbol_info_tick(currency).time) is 7h behind GMT+2, or 7h behind what is shown in the MetaTrader5 terminal. These problems persist for all broker servers I have tried.
I'm trying to copy the last X ticks from a given currency, but am left with sporadic results.
Here I should be retrieving the last 50 ticks starting from the current server time. It partially works; the following output shows the correct tick (bid and ask), as they line up with what I see in MetaTrader. The problem is the number of ticks varies - sometimes only a single tick, other times 4, or 9, etc. instead of 50.
If I retrieve the last 50 ticks not from server time, but from local time (2h behind), then I get 50 ticks every time.
Another weird thing is that the server time retrieved from the last tick (mt5.symbol_info_tick(currency).time) is 7h behind GMT+2, or 7h behind what is shown in the MetaTrader5 terminal. These problems persist for all broker servers I have tried.