MT5 API copy_rates_from returns nothing

 

Hello,


I'm trying to pull candle data, copy_rates_from and copy_rates_from_pos return no data.


Snippet of my code:

timezone = pytz.timezone('US/Eastern')

utc_from = datetime.datetime(2023, 1, 1, tzinfo=timezone)

rates = mt5.copy_rates_from("EURUSD", mt5.TIMEFRAME_M5, utc_from, 100)

for rate in rates:

customlog.printlog(rate)


Error:

for rate in rates:

TypeError: 'NoneType' object is not iterable


(This is not the full code, I do initialize first, MT5 successfully opens)

I have looked around for a solution.

I tried with and without first logging into the platform.

I tried changing symbols, timeframes, timezones and candle count. No difference.

I tried rewriting the exact example from the API documentation, no difference.

The method never returns any data.