How to add account number protection.

 
Hello, i need to insert in my code the account number protection, because i want to use the EA on a specific account number, i've tried but it shows me ever an error on it.
 
Angelo Speciale:
Hello, i need to insert in my code the account number protection, because i want to use the EA on a specific account number, i've tried but it shows me ever an error on it.
const int ACCOUNT_NUMBER = 11111111;

int OnInit()
  {
   if(AccountNumber() != ACCOUNT_NUMBER)
     {
      Alert("Wrong account number: ", AccountNumber());
      return(INIT_FAILED);
     }
   // ...
   return(INIT_SUCCEEDED);
  }
 
Vladislav Boyko #:

This is for MT4. For MT5 use AccountInfoInteger instead of AccountNumber().

And

const long ACCOUNT_NUMBER = 11111111;

instead of

const int ACCOUNT_NUMBER = 11111111;
Documentation on MQL5: Account Information / AccountInfoInteger
Documentation on MQL5: Account Information / AccountInfoInteger
  • www.mql5.com
AccountInfoInteger - Account Information - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Vladislav Boyko #:

This is for MT4. For MT5 use AccountInfoInteger instead of AccountNumber().

And

instead of

Thank you very much.