Values of bid and ask from mql5-python stream are different than those from metatrader-5?

 

Hello i just started mql5 python today. I used the example tutorial. They work well but only values (bid price and ask price) are different.

For example: when i run example code in "https://www.mql5.com/en/docs/integration/python_metatrader5" on python it prints current bid value as 85.334 and ask value as 85.351 

But if i check the values on metatrader 5 (windows app) it shows bid=85.254 and ask=85.271. I attached a screenshot, please check it.


I changed the original code as follows to get current values.

if not mt5.initialize(login=xxxx, server="VantageFXInternational-Demo",password="xxxxx"):

           print("initialize() failed")

    mt5.shutdown()


 ticks = mt5.copy_ticks_from("AUDJPY", datetime(year,month,day,hour,minute,second), 1, mt5.COPY_TICKS_ALL)

ticks_frame = pd.DataFrame(ticks)

ask=ticks_frame['ask'][0]

bid=ticks_frame['bid'][0]

print(ask, bid)

Documentation on MQL5: Integration / MetaTrader for Python
Documentation on MQL5: Integration / MetaTrader for Python
  • www.mql5.com
MetaTrader for Python - Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Files:
Untitled.png  18 kb
 

 ticks = mt5.copy_ticks_from("AUDJPY", datetime(year,month,day,hour,minute,second), 1, mt5.COPY_TICKS_ALL)


I noticed that mt5.copy_ticks_from returns earlier data. For example when i give time as ( ticks = mt5.copy_ticks_from("AUDJPY", datetime(2021,5,13,14,12,33), 1, mt5.COPY_TICKS_ALL)) it returns data of 2021-05-13 05:44:34. I added this  (timezone = pytz.timezone('Asia/Seoul')) already but no luck.

Check the attached screenshot. the red line indicates the date and time that i provided, and the green line indicates the date and time of the returned data.

Any help?

Files:
Untitled.png  12 kb
 
Ganbayar Batchuluun #:

I noticed that mt5.copy_ticks_from returns earlier data. For example when i give time as ( ticks = mt5.copy_ticks_from("AUDJPY", datetime(2021,5,13,14,12,33), 1, mt5.COPY_TICKS_ALL)) it returns data of 2021-05-13 05:44:34. I added this  (timezone = pytz.timezone('Asia/Seoul')) already but no luck.

Check the attached screenshot. the red line indicates the date and time that i provided, and the green line indicates the date and time of the returned data.

Any help?

You must use

symbol_info_tick  for the last tick.