error code: (-2, 'Terminal: Invalid params')

 

Good day, can someone please help me. I login into my account, it keeps showing me this  (error code: (-2, 'Terminal: Invalid params')) in the console when I run the code.

Here is what I've got. (Still new)


import MetaTrader5 as mt5
import pandas as pd

'''
mt5.login(
   login=140744,
   password="naohds2b",
   server="Quicktrade-Live",
   timeout=60000
   )
'''

print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)

if not mt5.initialize():
    print("initialize() failed, error code =",mt5.last_error())
    quit()

account=140744
authorized=mt5.login(account, password="naohds2b")
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()))
 

mt5.shutdown()

OOP in MQL5 by Example: Processing Warning and Error Codes
OOP in MQL5 by Example: Processing Warning and Error Codes
  • www.mql5.com
The article describes an example of creating a class for working with the trade server return codes and all the errors that occur during the MQL-program run. Read the article, and you will learn how to work with classes and objects in MQL5. At the same time, this is a convenient tool for handling errors; and you can further change this tool according to your specific needs.
 

I have the same error.  What is the solution?  Thanks.

 

The following code works just fine:

if not mt5.initialize(login=account, password=password, server=server):
    print("initialize() failed, error code =",mt5.last_error())
    quit()
authorized=mt5.login(account, password=password, server=server)

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()))