MT5 Strategy Tester questions

 

Hi all,

I have two questions regarding the Strategy Tester in MT5. Maybe someone knows the answer:

  1. Are function calls to Print() and PrintFormat() automatically disabled during optimization, or should I rather check for MQLInfoInteger(MQL_OPTIMIZATION) before using them? My EA is quite verbose when it comes to logging and during normal backtesting I noticed that this can slow down the whole process quite a bit.
  2. Is there any way to test the current day in the Strategy Tester, without having to wait until midnight? When I select View > Symbols > Ticks, I see that they are already there as they come in for the current day. So I wonder why the Strategy Tester will not use them, even when setting an end date in the future.
Thank you in advance.
 
Eric Emmrich: Are function calls to Print() and PrintFormat() automatically disabled during optimization, or should I rather check for MQLInfoInteger(MQL_OPTIMIZATION) before using them? My EA is quite verbose when it comes to logging and during normal backtesting I noticed that this can slow down the whole process quite a bit.

During optimisation, output from Print() and PrintFormat() is suppressed (and does not go out to the log).

This is stated in the documentation, so please read it ...

  • "Print() function does not work during optimization in the Strategy Tester."
  • "PrintFormat() function does not work during optimization in the Strategy Tester."
 
Eric Emmrich: Is there any way to test the current day in the Strategy Tester, without having to wait until midnight? When I select View > Symbols > Ticks, I see that they are already there as they come in for the current day. So I wonder why the Strategy Tester will not use them, even when setting an end date in the future.

The option was deliberately disabled by MetaQuotes to prevent certain types of "abuse", but one way to work around it is to create a custom symbol with the data offset in time.

 

Always here to help :) Many thanks, Fernando!

That answers all my questions. Will give the suggested custom symbol a try then.

 

Eric Emmrich:

Are function calls to Print() and PrintFormat() automatically disabled during optimization, or should I rather check for MQLInfoInteger(MQL_OPTIMIZATION) before using them? My EA is quite verbose when it comes to logging and during normal backtesting I noticed that this can slow down the whole process quite a bit.

Try.

input int inRange = 0;

double Calc()
{
  double Sum = 0;
  
  for (int i = 0; i < 1e5; i++)
    Sum += MathSin(MathRand());
    
  return(Sum);
}

void OnTick()
{
  static const bool Flag = !MQLInfoInteger(MQL_OPTIMIZATION) && !MQLInfoInteger(MQL_FRAME_MODE);
  
//  if (Flag)
    Print(Calc());
}

There will be no printout, but there will be calculations.

 
fxsaber #:

Try.

There will be no printout, but there will be calculations.

Very interesting, thank you very much! I'm doing some on-demand calculations in some of my Print() calls indeed. Will move them out of the calls then.