Function to detect if EA running in Backtest or not

 

Hi,

I want a simple way to determine whether an EA is running in a System Test or if it is running on a chart.

How can I do this?

I know it must involve using the OnTester() function, but I'm not sure exactly how to achieve this.

I was thinking if there is a way to create some global variable that the OnTester function could then update, perhaps?

The reason for this is because I want to run different code depending upon whether the EA is executing in a System Test or not.

That is to say,

If (OnTester() == TRUE {

  do Test Functions;

} Else {

  do Realtime Functions;

}

 
if(MQLInfoInteger(MQL_TESTER))
      {
      ////
      }

.

 
Keith Watford #:

.

Thanks, I will give that a try.

Reason: