'How to call MetaTrader5 `initialize()` with login information?

when I use initialize function without parameters the connection is established correctly. but when I add any parameter like the 'login' it is not working



account=#account_number
authorized=mt5.initialize()

if authorized:
    print("connected to account #{}".format(mt5.account_info()))
else:
    print("failed to connect at account #{}, error code: {}".format(account, mt5.last_error()))

using the above code will connect correctly

but when I edit it like that authorized=mt5.initialize(login=account)

it won't connect and give me this error and I am sure of my account number and all the other details failed to connect at account #53895161, error code: (-2, 'Terminal: Invalid params')



Solution 1:[1]

mt5.initialize() Establish a connection with the MetaTrader 5 terminal.

use mt5.login() for login:

authorized = mt5.login(1234, password = "password", server="server")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 M.a.RS