Simple code - but it does not work. Why?

 
I need to secure my EA so that it is freely available on demo accounts but require registration when used on a live account. I wrote some simple code, but it does not work in spite of having the correct Account numbers. Can you help me?
      if(IsDemo()) return(INIT_SUCCEEDED);
      
      if(!IsDemo()) 
      
      {
      
      int AccountNo[2] ={336403, 999004016};
      
      i=0; i <= 2; i++;
      
      if (AccountNumber() == AccountNo[i])
      
      return(INIT_SUCCEEDED);
      
      else
      
      Print("You don't have permission to use this Expert Advisor on a live account! Contact Forex Academy for a valid version based on your MT4 account number");
    
 
You loop isn't a loop! Just have a look in the doc how a for statement is build!
 
Ernest Klokow: I need to secure my EA so that it is freely available on demo accounts but require registration when used on a live account. I wrote some simple code, but it does not work in spite of having the correct Account numbers.
int OnInit()
{
   if( IsDemo() ) return( INIT_SUCCEEDED );
      
   int AccountNo[] = { 336403, 999004016 };
   for( int i = ArraySize( AccountNo ) - 1; i >=0; i-- )
      if ( AccountNumber() == AccountNo[ i ] )
         return(INIT_SUCCEEDED);
      
   Print( "You don't have permission to use this Expert Advisor on a live account! Contact Forex Academy for a valid version based on your MT4 account number" );
   return( INIT_FAILED );
}

Alternative MQL4+ (MQL5 compatibility):

int OnInit()
{
   if( AccountInfoInteger( ACCOUNT_TRADE_MODE ) == ACCOUNT_TRADE_MODE_DEMO ) return( INIT_SUCCEEDED );
      
   long AccountNo[] = { 336403, 999004016 };
   for( int i = ArraySize( AccountNo ) - 1; i >=0; i-- )
      if ( AccountInfoInteger( ACCOUNT_LOGIN ) == AccountNo[ i ] )
         return(INIT_SUCCEEDED);
      
   Print( "You don't have permission to use this Expert Advisor on a live account! Contact Forex Academy for a valid version based on your MT4 account number" );
   return( INIT_FAILED );
}
 
Carl Schreiber:
You loop isn't a loop! Just have a look in the doc how a for statement is build!

Thank you Carl.  You have been a GREAT help! 

 
Fernando Carreiro:

Alternative MQL4+ (MQL5 compatibility):


Fernando,

Thank you SO MUCH that you took the time to help this struggling programmer. It is people like you that makes the world a better place!

Reason: