Python MetaTrader5 can't obtain 1 minute price bars


Hello! Recently I stumbled upon MetaTrader5 python package, so I tried to use it to read price data from MT5. I'm using XM MT5 platform as my MT5.

To the point. I run this chunk of code:

from datetime import datetime
import MetaTrader5 as mt5
# display data on the MetaTrader 5 package
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)

# establish connection to MetaTrader 5 terminal
if not mt5.initialize():
    print("initialize() failed, error code =",mt5.last_error())

utc_from = datetime(2020, 1, 10)

rates = mt5.copy_rates_from("EURUSD", mt5.TIMEFRAME_M1, utc_from, 1000)
print("Bars received:",len(rates))

# shut down connection to the MetaTrader 5 terminal

And the result of this code is this attached photo.

I will be glad for any help or suggestions. Thanks a lot

p2.jpg  19 kb

Your code and your screenshot don't match! Your code has the message "Bars received:" but your screenshot has the message "Ticks received:".

now should be ok, i did not change print from the example
Jakub Bednarek #: now should be ok, i did not change print from the example
  1. How much data is available in MetaTrader for EUR/USD M1 and for what date range?
  2. You printed the date as a number "1669330500", but what is the date-time representation for it?
Please note that I am not a Python program and I am helping based on knowledge of MQL5.
I really can't tell why, but today I tried to run the code and it returns price bars and OHLCV data like it should. Thanks for trying to help @Fernando Carreiro :)
Jakub Bednarek #: Thanks for trying to help @Fernando Carreiro :)
You are welcome!