MetaTrader5 Tick Values Inaccurate?

 

Very simple, I'm retrieving tick data as follows:

ticks = mt5.copy_ticks_from("AUDJPY", time.time(), 10, mt5.COPY_TICKS_INFO)

print(ticks)
which prints:

[ (1705508465, 96.753, 96.759, 96.756, 0, 1705508465232, 6, 0.)

 (1705508465, 96.755, 96.761, 96.758, 0, 1705508465255, 6, 0.)
 (1705508465, 96.753, 96.761, 96.757, 0, 1705508465292, 2, 0.)
 (1705508465, 96.755, 96.761, 96.758, 0, 1705508465330, 2, 0.)
 (1705508465, 96.755, 96.76 , 96.758, 0, 1705508465462, 4, 0.)
 (1705508465, 96.755, 96.759, 96.757, 0, 1705508465490, 4, 0.)
 (1705508465, 96.754, 96.761, 96.758, 0, 1705508465532, 6, 0.)
 (1705508465, 96.754, 96.759, 96.757, 0, 1705508465550, 4, 0.)
 (1705508465, 96.755, 96.76 , 96.758, 0, 1705508465593, 6, 0.)
 (1705508465, 96.755, 96.761, 96.758, 0, 1705508465613, 4, 0.)]


I know I'm retrieving the "right" values, because the UNIX time is correct. Yet the tick value is completely off. In the attached image (5m timeframe), you can see the prices are all 96.90+, but for those same candles, the tick data is returning 96.755 and such. What is going on?

MQL5.community - User Memo
MQL5.community - User Memo
  • www.mql5.com
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
Files:
2.PNG  4 kb
 
scarbo_: I know I'm retrieving the "right" values, because the UNIX time is correct. Yet the tick value is completely off. In the attached image (5m timeframe), you can see the prices are all 96.90+, but for those same candles, the tick data is returning 96.755 and such. What is going on?

You are mixing up the concepts of local time and trade server time. They are not necessarily the same.

Trade servers can use completely different time-zone and DST.

Look at the time legend at the bottom of the MT5 chart.

 
Fernando Carreiro #:

You are mixing up the concepts of local time and trade server time. They are not necessarily the same.

Trade servers can use completely different time-zone and DST.

Look at the time legend at the bottom of the MT5 chart.

Ah yes, thanks. What a silly thing to forget to consider
 
Fernando Carreiro #:

You are mixing up the concepts of local time and trade server time. They are not necessarily the same.

Trade servers can use completely different time-zone and DST.

Look at the time legend at the bottom of the MT5 chart.

Some problems arise still. To determine the timezone of the MT5 server or the UTC offset from python, I see a previous suggestion was to wait for a tick to arrive, then compare the time of tick with the current local time, and use that difference to calculate the offset. However, how do I receive a most recent tick? That's the entire goal! I just want to receive the most recent ticks available, but I can only receive ticks from the specified time, in this case time.now() of my local time zone (which results in the problem originally mentioned in this thread). Without knowing the offset, there is no way for me to retrieve the latest tick from MT5's server time? Do I really have to hardcode the time zone and adjust it everytime DST comes about?
Documentation on MQL5: Date and Time / TimeLocal
Documentation on MQL5: Date and Time / TimeLocal
  • www.mql5.com
TimeLocal - Date and Time - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
scarbo_ #:
Some problems arise still. To determine the timezone of the MT5 server or the UTC offset from python, I see a previous suggestion was to wait for a tick to arrive, then compare the time of tick with the current local time, and use that difference to calculate the offset. However, how do I receive a most recent tick? That's the entire goal! I just want to receive the most recent ticks available, but I can only receive ticks from the specified time, in this case time.now() of my local time zone (which results in the problem originally mentioned in this thread). Without knowing the offset, there is no way for me to retrieve the latest tick from MT5's server time? Do I really have to hardcode the time zone and adjust it everytime DST comes about?
You can use this function to get the last tick received.




 
Dominik Egert #:
You can use this function to get the last tick received.

I tried symbol_info_tick; do you have any idea why the server time received with this method is 7 hours behind GMT+2? On both MetaQuotes server and Oanda server, somehow the apparent server time, the latest tick via symbol_info_tick is EST timezone, despite MetaTrader (the candles and Market Watch) showing as GMT+2. 7h ahead. It makes no sense to me.


As a side, the following code ideally would print the last 200 ticks for each currency. What I get, however, is an incomplete list of ticks, printing anywhere from 1 to 15 ticks, but never 200. If I use my local time time.time() instead of server_time, then it prints the full 200 ticks every time.

latest_tick = mt5.symbol_info_tick("EURUSD")
server_time = latest_tick.time # e.g. UNIX 1705647839

for currency in currencies_list:
        ticks = mt5.copy_ticks_from(currency, server_time, 200, mt5.COPY_TICKS_INFO)
        print(ticks)
 
scarbo_ #:

I tried symbol_info_tick; do you have any idea why the server time received with this method is 7 hours behind GMT+2? On both MetaQuotes server and Oanda server, somehow the apparent server time, the latest tick via symbol_info_tick is EST timezone, despite MetaTrader (the candles and Market Watch) showing as GMT+2. 7h ahead. It makes no sense to me.


As a side, the following code ideally would print the last 200 ticks for each currency. What I get, however, is an incomplete list of ticks, printing anywhere from 1 to 15 ticks, but never 200. If I use my local time time.time() instead of server_time, then it prints the full 200 ticks every time.

Since you are connected to MQ Demo, I guess, you received an update to MT this week, if so, you are on a beta build. - Please disconnect your MQ Demo account and get the current build (4040). Then retest the situation.

If it persists, we need to investigate further.
 
Dominik Egert #:
Since you are connected to MQ Demo, I guess, you received an update to MT this week, if so, you are on a beta build. - Please disconnect your MQ Demo account and get the current build (4040). Then retest the situation.

If it persists, we need to investigate further.

I'm looking on the "About" section in MetaTrader and it states Version: 5.00 build 4150, 18 Jan 2024. Is this not the most updated build? The problem persists.

Edit: Problem persists on build 4153, Jan 22 2024