I've got multiple python programs that connect to Mt5 terminal using the following code.
# Establish connection to the MetaTrader 5 terminal
if not mt5.initialize("C:\\Program Files\\ICMarkets - MetaTrader 5 - 01\\terminal64.exe"):
print("initialize() failed, error code =", mt5.last_error())
quit()
The python module for MT5 is the one here - https://www.mql5.com/en/docs/integration/python_metatrader5
The problem I have is that, when multiple programs connect to the same MT5 terminal.exe
, the performance degrades & one or more python programs exit with errors. To overcome this, I have installed multiple copies of MT5 & have updated the python code such that different copies of python program use different installations of MT5. However, only the first installation of MT5 is the only one that can be invoked by all the python programs. Trying to use any other terminal.exe
from other installation raises an exception & the connection fails.
There isn't much on the internet either to troubleshoot this. If anyone has ideas to tackle this or has solved the problem, I'd be keen to hear from you please.
The error as such is -
initialize() failed, error code = (-10003, "IPC initialize failed, Process create failed 'C:\\Program Files\\ICMarkets - MetaTrader 5 - 02\terminal64.exe'")
This could be something to do with Windows's default pointing to the first installation or something like that that you wouldn't even think about. Just thinking aloud here.