How to protect my EA with multiple account number

 
int liveAccountNumber = 535621;
int liveAccountNumber2 = 737213;

if(( AccountNumber()  liveAccountNumber) && ( AccountNumber()  liveAccountNumber2))

Hello, I am trying to do in this way but it is not working for the second or multiple account number. I want to get a code that will allow my EA only for some accounts. If the account number do not match between two or more accounts then EA will not work.

Please, help me to do this. Advice me the correct code.Thanks in advanced.

 
long login=AccountInfoInteger(ACCOUNT_LOGIN);
try this
 
Taras Slobodyanik:
try this

Would you please explain me a little, where and how to use this code?
 
int liveAccountNumber = 535621;
int liveAccountNumber2 = 737213;

int start() {
if(( AccountNumber() == liveAccountNumber) || ( AccountNumber() == liveAccountNumber2))
{
   Print("Account Number recognized.thanks");
   Alert("Account Number recognized.");
   return(1);
}
else
{
   Print("Account Number not recognized.");
   Alert("Account Number not recognized,Contact EA author to validate account");
   return(-1);
}
}
Your if logic is incorrect. I've made the changes for you.
 
Meng Yin Teoh:
Your if logic is incorrect. I've made the changes for you.
these is work for me... very nice.thank you Meng...
 

There is a better way to do this... Add as few or many account numbers to an array with an initialization list and then iterate over the list to find a matching account number. 

void OnStart()
{
   int my_acc = (int)AccountInfoInteger(ACCOUNT_LOGIN);
   //--- add as many accounts as necessary -- example-
   int auth_accounts[] = { 123456, //live 1
                           123457, //live 2
                           123458, //demos
                           123459,
                           123444
                         };
   bool is_auth = false;
   for(int i=0;i<ArraySize(auth_accounts);i++)
      if(auth_accounts[i] == my_acc)
         is_auth = true;
 
   if(!is_auth)
      Print("Account not authorized!");
   else
      Print("Your account is authorized");
}
 
sakibco:

Would you please explain me a little, where and how to use this code?

And what code are you going to "protect" when you are not familiar with a simple function that returns account number usage ?

Summer :) Always the same ... :)

 
nicholi shen:

There is a better way to do this... Add as few or many account numbers to an array with an initialization list and then iterate over the list to find a matching account number. 

i like this - I'm still on my quest to find a way to extract from a CSV via drive.google.com

Love that this works with account numbers :)

 
forexnuggets:

i like this - I'm still on my quest to find a way to extract from a CSV via drive.google.com

Love that this works with account numbers :)

Actually if I figure this out I'll post :)

Multiple AccountName(). I gotta use a string not an integer I believe. I like the above as far as i++ to go thru a list, just gotta have it read characters and not numbers
Reason: