I am trying to login to Metatrader5 account and I have been receiving this error code.
Please see code below;
I first import necessary libraries and initialize which works fine
import MetaTrader5 as mt5
mt5.initialize()
But when I try to log in using the below code, I receive this error -
failed to connect at account #51166970, error code: (-10005, 'IPC timeout') In [14]:
account=51166970
authorized=mt5.login(account, password='z6kjjrtr', server='ICMarketsSC-Demo')
if authorized:
print(mt5.account_info())
print("Show account_info()._asdict():")
account_info_dict = mt5.account_info()._asdict()
for prop in account_info_dict:
print(" {}={}".format(prop, account_info_dict[prop]))
else:
print("failed to connect at account #{}, error code: {}".format(account, mt5.last_error()))
I also read some post about similar errors which asked I specify the path, please see post links (MetaTrader5 libarary in Python 3.7 and MT5/Metatrader 5 connect to different MT5 terminals using python and https://www.mql5.com/en/forum/438477), so I edited my code but received this error - initialize() failed, error code = (-10005, 'IPC timeout')
As noted in an answer here (metatrader error initialize() failed, error code = (-10005, 'IPC timeout')) I changed my path from
"C:\Program Files\MetaTrader 5\terminal64.exe"
to
"C:/Program Files/MetaTrader 5/terminal64.exe"
#start the platform with initialize()
if not mt5.initialize("C:/Program Files/MetaTrader 5/terminal64.exe", login=22000642, password="duzhhjkd8", server="Deriv-Demo"):
print("initialize() failed, error code =", mt5.last_error())
else:
mt5.login(login=22000642, password='duzhhjkd8', server='Deriv-Demo')
How can I rectify this error?