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); }
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); }
- 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 - 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:
- 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 - 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...

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
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