EA account check not properly working

 

I couldn't figure out why these happening EA auth check  not working properly when account number changed its suppose to exit expertadvisor but its still working on it for same chart if itsnot changed which account restriction become useless what's wrong in it what modify i need to do 


/*

bool CheckOK()
{
   Print("Please wait, running security check.....");
   string broker=AccountInfoString(ACCOUNT_COMPANY);
   long account=AccountInfoInteger(ACCOUNT_LOGIN);

   if (allowed_broker=="FXCM") Print("The program is allowed to run on your broker, ",broker);
   else if(broker==allowed_broker)  Print("The program is allowed to run on your broker, ",broker);
   else
   {
      Print("The program is not allowed to run on your broker, ",broker);
      return(false);
   }

   int AS=ArraySize(allowed_accounts);
   if (AS>0)
   {
      for(int i=0; i<ArraySize(allowed_accounts); i++)
      {
         if(account==allowed_accounts[i])
         {
            password_status=1;
            Print("Account verified. The program can run on your Account #",account);
            break;
         }
       }
       if (password_status==-1)
       {
         Print("The program is not allowed to run on this Account #",account);
         return(false);
       }
   }
   else Print("No account number restrictions in place. The program can run on your Account #",account);
   
   Print("This program is valid until %s",TimeToString(allowed_until,TIME_DATE|TIME_MINUTES));
   if(now<allowed_until)      
   {
      Print("The program time limit is verified OK");
   }
   else
   {
      Print("The program cannot run, the time limit has expired.");
      return(false);
   }
   return(true);
}


*/

 
  1. Please use the SRC-button (beside the camera) for your source code
  2. you never (in your code snippet) set password_status to -1 so one set to 1 it remains 1!
 
Carl Schreiber:
  1. Please use the SRC-button (beside the camera) for your source code
  2. you never (in your code snippet) set password_status to -1 so one set to 1 it remains 1!

first i don't know how edit my post for src i use this opiton on next post

now coming question like you said ,i already used password_status =-1  when password _status = 1 is to proceed but my problem everything working fine only at attaching ea . I mean when i switch my one account to another account with same broker it doesn't works (not terminating) that too only that chart if attached ea its terminating

Note: OnlyAccountNumber Based i made code for broker but most case i wouldn't use broker or name

 
metapark:

first i don't know how edit my post for src i use this opiton on next post

...

Place your mouse on the bottom right corner of your post and click on the edit link.

 

Hello,

I did this as a test. I don't use it, but might be some help for you

if (AccountNumber()!=My_Account)Wrong_Account;
if (AccountNumber()!=My_Account)

and this

void Wrong_Account(){MessageBox("You Do Not Have The Correct Account Number. ","Account Information Incorrect ",0);}
 
GrumpyDuckMan:

Hello,

I did this as a test. I don't use it, but might be some help for you

and this

Thanks you Grumpy, but i need to use it in multiple ACCOUNT NUMBER in single file, if you look at

int OnInit()
  {
  
     // Account locking
   if (AccountLocking)
   {
      
      if (initSecurityCheckOK()==true) 
      {
         Print("Security check successful. Welcome ",AccountInfoString(ACCOUNT_NAME));
         Comment("Security check successful. Welcome ",AccountInfoString(ACCOUNT_NAME));
         
      }
      else                 
      {
         Print("Security check failed. The program will now terminate. Goodbye ",AccountInfoString(ACCOUNT_NAME));
         Comment("Security check failed. The program will now terminate. Goodbye ",AccountInfoString(ACCOUNT_NAME));
         return(INIT_FAILED);
      }
   }



//
 int AS=ArraySize(allowed_accounts);
   if (AS>0)
   {
      for(int i=0; i<ArraySize(allowed_accounts); i++)
      {
         if(account==allowed_accounts[i])
         {
            password_status=1;
            Print("Account verified. The program can run on your Account #",account);
            break;
         }
       }
       if (password_status==-1)
       {
         Print("The program is not allowed to run on this Account #",account);
         return(false);
       }
   }
   else Print("No account number restrictions in place. The program can run on your Account #",account);
   
   Print("This program is valid until %s",TimeToString(allowed_until,TIME_DATE|TIME_MINUTES));
   if(now<allowed_until)      
   {
      Print("The program time limit is verified OK");
   }
   else
   {
      Print("The program cannot run, the time limit has expired.");
      return(false);
   }
   return(true);
}

like you said AccountNumber()!=account working charm but i need this to work with multiple account . pls retify if i made any  like codeerror


int AS=ArraySize(allowed_accounts);
Reason: