Download MetaTrader 5
To add comments, please log in or register
Deposit to your account in any convenient way. There are 4 of them here!
Route206
211
Route206 2015.06.16 14:12 

Apologies for what could potentially be a stupid question, but i just don't seem to be able to figure it out: Can someone help me in terminating an EA when during OnInit() it find certain parameters, values etc unacceptable?

something like the below: 

OnInit()
   {   
   if(certain_variable == acceptable)
      {continue;}
      else
      {Alert("Unacceptable input for ",certain_variable," pls check and start over");
      SOMETHING_THAT_TERMINTES_THIS_EA();}
   return;
   }

 I can put in all the Alerts i want, but the things starts and then crashes when indeed inputs are off.

thank,

Ron. 

Gordon Gekko
656
Gordon Gekko 2015.06.16 14:29  
Route206:

Apologies for what could potentially be a stupid question, but i just don't seem to be able to figure it out: Can someone help me in terminating an EA when during OnInit() it find certain parameters, values etc unacceptable?

something like the below: 

 I can put in all the Alerts i want, but the things starts and then crashes when indeed inputs are off.

thank,

Ron. 

ExpertRemove()

Cheers

Route206
211
Route206 2015.06.16 14:33  
ggekko:

ExpertRemove()

Cheers

thanks a bunch - i knew it had to be something simple ;-)
whroeder1
13619
whroeder1 2015.06.16 16:25  
Route206: terminating an EA when during OnInit() it find certain parameters, values etc unacceptable?
OnInit()
   {   
   if(certain_variable == acceptable)
      {continue;} << can't use continue outside of a loop.
      else
      {Alert("Unacceptable input for ",certain_variable," pls check and start over");
      SOMETHING_THAT_TERMINTES_THIS_EA();}
   return;
   }
Event Handling Functions - MQL4 Documentation
int OnInit()
   {   
   if(certain_variable != acceptable)
      {Alert("Unacceptable input for ",certain_variable," pls check and start over");
      return INIT_PARAMETERS_INCORRECT;}
   return INIT_SUCCEEDED;
   }
Route206
211
Route206 2015.06.18 06:25  

Yes... clearly a much beter to handle that, thanks so much!

That said, as a newbie, '#property strict' is not my friend yet.... ;-) 

Alain Verleyen
Moderator
28606
Alain Verleyen 2015.06.18 07:10  
Route206:

Yes... clearly a much beter to handle that, thanks so much!

That said, as a newbie, '#property strict' is not my friend yet.... ;-) 

As a newbie you should use #property strict in all cases. Otherwise you will acquire bad habits.
Route206
211
Route206 2015.06.18 14:08  
angevoyageur:
As a newbie you should use #property strict in all cases. Otherwise you will acquire bad habits.
Oh.. believe me, i have plenty! ;-)
/
To add comments, please log in or register