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?
- Help needed
- Experts: GoodG@bi Review
- PositionsTotal() function doesn't get the number of the opened positions
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!
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!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register