Problem with non-visual backtest

 

Hello everyone.

I came across a strange behavior where there were wrong results in non-visual backtest. Finally I realized that retrieving custom indicator values using CopyBuffer on every new tick(up in OnTick function) resolves the issue. Does anyone have a similar experience and can you make it clear why this is happening?

 
Yashar Seyyedin:

I came across a strange behavior where there were wrong results in non-visual backtest. Finally I realized that retrieving custom indicator values using CopyBuffer on every new tick(up in OnTick function) resolves the issue. Does anyone have a similar experience and can you make it clear why this is happening?

The tester works so by default, by design - MQ did so for the sake of efficiency.

You should read about #property tester_everytick_calculate and add it into your indicator source code, then you will no need to call CopyBuffer on every tick - the tester will recalculate indicator on every tick automatically, but this can negatively affect performance.

Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
  • www.mql5.com
Every mql5-program allows to specify additional specific parameters named #property that help client terminal in proper servicing for programs...
 
Stanislav Korotky #:

The tester works so by default, by design - MQ did so for the sake of efficiency.

You should read about #property tester_everytick_calculate and add it into your indicator source code, then you will no need to call CopyBuffer on every tick - the tester will recalculate indicator on every tick automatically, but this can negatively affect performance.

Thanks for the great information.