Block EA from running on strategy tester

 

Here is the simple EA code which gives an Alert when initialized on the chart..

int OnInit()

{

 Alert("The EA is Initialized");

return(INIT_SUCCEEDED);

}


I want to lock this EA to not run its code on strategy tester. How can I do that?

Thanks & Regards

Naren

 
Use IsTesting() to check if EA is running in strategy tester
 
naren292000:

Here is the simple EA code which gives an Alert when initialized on the chart..

int OnInit()

{

 Alert("The EA is Initialized");

return(INIT_SUCCEEDED);

}


I want to lock this EA to not run its code on strategy tester. How can I do that?

Thanks & Regards

Naren


int OnInit()
{
if(IsTesting())
  {
  Alert("...");
  return(INIT_FAILED);
  }
return(INIT_SUCCEEDED);
}
 
Fabio Cavalloni:
Use IsTesting() to check if EA is running in strategy tester

Hi 

Thank you so much for your answer... You made my work simple :-)

so Here is the code to block EA to not run on strategy tester


int OnInit()

{

 int A = IsTesting();

 if(A != 1)

 Alert("EA is Initialized");

return(INIT_SUCCEEDED);

}

 
Kenneth Parling:


Hi Thank you so much for your answer :-)

 

why you like to do this?

 
naren292000: so Here is the code to block EA to not run on strategy tester

int OnInit(){
 int A = IsTesting();
 if(A != 1)
    Alert("EA is Initialized");
return(INIT_SUCCEEDED);
}

  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. IsTesting does not return an int. Your code doesn't block anything. It only Alerts if you are using the tester or optimizer but not the debugger or live trading.
              Write logging data to text file? - MQL5 programming forum #3 20.04.21
 
William Roeder:
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. IsTesting does not return an int. Your code doesn't block anything. It only Alerts if you are using the tester or optimizer but not the debugger or live trading.
              Write logging data to text file? - MQL5 programming forum #3 20.04.21

Thank you for your reply and suggestions..

Will follow it...