MetaTrader 5 Python User Group - the summary - page 17

 
nicholi shen:

If everything works when you call initialize without args but breaks when you try and call it with args, then you are inputting something wrong. 

thats the weird part 

it never worked (with args or without args).....it always just launches the metatrader and never logs in 

it only logs in when i use the metatrader platform of the broker that the  account is registered with 
on any other metatrader it always only launches the platform and try to login the account but never completely logs in the account 

 
mhdumer016:

thats the weird part 

it never worked (with args or without args).....it always just launches the metatrader and never logs in 

it only logs in when i use the metatrader platform of the broker that the  account is registered with 
on any other metatrader it always only launches the platform and try to login the account but never completely logs in the account 

Your user credentials are wrong. When you login manually and then use python without args it works. If you then use the wrong user creds it will logout the current user and remain in a state of disconnection to the trade server until you either login manually with correct credentials (stored in Terminal settings) or you use the correct credentials in the python script. 

 
nicholi shen:

Your user credentials are wrong. When you login manually and then use python without args it works. If you then use the wrong user creds it will logout the current user and remain in a state of disconnection to the trade server until you either login manually with correct credentials (stored in Terminal settings) or you use the correct credentials in the python script. 


yeah i cleared that doubt yesterday....

i copied the login credentials from the python script to login manually , if the credentials were wrong in the script then it wouldnt have logged in manually either 

 
mhdumer016:


yeah i cleared that doubt yesterday....

i copied the login credentials from the python script to login manually , if the credentials were wrong in the script then it wouldnt have logged in manually either 

Run this and make sure one of the terminal paths is exactly what you are using for the path param. Open the terminal at that path and confirm that it is MT5 and the build is >= 2375

from pathlib import Path

terminals = (x for p in Path('C:\\').glob('**/terminal64.exe') if 'filehistory' not in (x:=str(p)).lower())
for terminal in terminals:
    print(terminal)
 
nicholi shen:

Run this and make sure one of the terminal paths is exactly what you are using for the path param. Open the terminal at that path and confirm that it is MT5 and the build is >= 2375

okay so it wont work with mt4?

sorry i messed up 
i was trying to use it to initialize mt4

 
mhdumer016:

okay so it wont work with mt4?

sorry i messed up 
i was trying to use it to initialize mt4

No. MT5 ONLY

 
nicholi shen:

No. MT5 ONLY

its a bit funny tho , cuz the same script works on mt4 platform if the mt4 is from the same broker as the account provider
 
mhdumer016:
its a bit funny tho , cuz the same script works on mt4 platform if the mt4 is from the same broker as the account provider

When you call initialize without args it defaults to the last opened MT5 terminal and login credentials. Your script was opening an MT5 terminal. 

 
nicholi shen:

When you call initialize without args it defaults to the last opened MT5 terminal and login credentials. Your script was opening an MT5 terminal. 

nope ...i am sure it was opening mt4 when i initialize the path to mt4 terminal
 
mhdumer016:
nope ...i am sure it was opening mt4 when i initialize the path to mt4 terminal

It can launch (open) the terminal if you targeted it with the path arg because the (subprocess) command is the same, but it cannot connect to the terminal.

Reason: