error(-4, 'Terminal: Not found')

 

I'm trying to run this code I got from the documentation page:

from datetime import datetime
import MetaTrader5 as mt5

# connect to MetaTrader 5
if not mt5.initialize():
    print("initialize() failed")
    mt5.shutdown()

# request connection status and parameters
print(mt5.terminal_info())
# get data on MetaTrader 5 version
print(mt5.version())

# request 1000 ticks from EURAUD
euraud_ticks = mt5.copy_ticks_from("EURAUD", datetime(2020,1,28,13), 1000, mt5.COPY_TICKS_ALL)
print('error ', mt5.last_error())

Everything run correctly but If I print the length of euraud_ticks, I got:

TypeError: object of type 'NoneType' has no len()

And mt5.last_error() returns (-4, 'Terminal: Not found')

And if I try printing mt5.version() after the error, It runs correctly.

 

Why did you post in the MetaTrader 4 section? The Python API is only available on MetaTrader 5.

Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893