I'm working on my EA with no prior experience in MQL5. Could you please advize on how to use account information (i.e. account #, account name, account trade mode) to protect my EA. Also, can I use the account number as the EA Magicnumber? I'll have many questions in the area of mone management and will appreciate your cooperation. I attached below the cose I'm using for your comment and help.
//---- input parameters
LONG_VALUE Account_Number // Account Numberstring Account_Name // AccountNameLONG_VALUE AccountLeverage // AccountLeverage
Use the CAccountInfo class to declare an instance of the account info object.. you must include the definition of the class:
//---- correct input declaration
input long Account_Number // Account Number
input string Account_Name // AccountName
input long Account_Leverage // AccountLeverage
//---- getting info
long account_number = MyAccount.Login();
string account_name = MyAccount.Name();
long account_leverage = MyAccount.Leverage();
//---- security code here...
Then compare these values to the input values or do it directly bypassing the use of local variables.
About using the account number as magic number: yes you can.