Switching between different Accounts

 

Hi 

Is there a way to toggle through different MT5 accounts using a mql5 script or EA?

I would like to do that for 2 reasons:

1.  to get the account balances from different MT5 accounts

2. close all open trades from different MT5 accounts

Is there anyone that can help me.

Thanks in advance.

 

Any ideas on how to do this?

 

Hi please see

initialize(
   path,                     // path to the MetaTrader 5 terminal EXE file
   login=LOGIN,              // account number
   password="PASSWORD",      // password
   server="SERVER",          // server name as it is specified in the terminal
   timeout=TIMEOUT,          // timeout
   portable=False            // portable mode
   )

 
Marco vd Heijden:

Hi please see

initialize(
   path,                     // path to the MetaTrader 5 terminal EXE file
   login=LOGIN,              // account number
   password="PASSWORD",      // password
   server="SERVER",          // server name as it is specified in the terminal
   timeout=TIMEOUT,          // timeout
   portable=False            // portable mode
   )

Thank you so much.
This was such a great help :-)

 

https://www.mql5.com/en/docs/integration/python_metatrader5/mt5initialize_py

If you read in the login credentials from an external file make sure to cast the account number to Int.

Documentation on MQL5: Integration / MetaTrader for Python / initialize
Documentation on MQL5: Integration / MetaTrader for Python / initialize
  • www.mql5.com
[in]  Path to the metatrader.exe or metatrader64.exe file. Optional unnamed parameter. It is indicated first without a parameter name. If the path is not specified, the module attempts to find the executable file on its own. [in]  Trading account password. Optional named parameter. If the password is not set, the password for a...
 

I have another question in regard to the path for mt5.initialize

I have this code in python

if not mt5.initialize(login=accNumber, server="ICMarkets-MT5",password=pword):

which works fine, now I want to add the path, and I have tried

if not mt5.initialize(path="E:\Programs\ICMarkets-MT5-Demo", login=accNumber, server="ICMarkets-MT5",password=pword):

which gives me this error

initialize() failed, error code = (-10003, "IPC initialize failed, Process create failed 'E:/Programs/ICMarkets-MT5-Demo'")

I have tried using \\ and / and // instead as well as single quote, all with the same result.


Any ideas?

 

You must include terminal64.exe in path. This worked for me: 

path1='C:\\Program Files\\Capitaria MT5 Terminal\\terminal64.exe'

path2='C:\\Program Files\\Admiral Markets MT5\\terminal64.exe'