is backtesting

 
is there a function that can detect that I'm doing a backtesting?
 
  1. Why do you care? Other than diagnostics during non-live/non-optimizer modes, you shouldn't be doing anything different.
  2. Test for it.
              Detect optimization mode programmatically - Expert Advisors - MQL5 programming forum (2020.05.15)
 
William Roeder #:
  1. Why do you care? Other than diagnostics during non-live/non-optimizer modes, you shouldn't be doing anything different.
  2. Test for it.
              Detect optimization mode programmatically - Expert Advisors - MQL5 programming forum (2020.05.15)
Thank you
 
William Roeder #:
  1. Why do you care? Other than diagnostics during non-live/non-optimizer modes, you shouldn't be doing anything different.
  2. Test for it.
              Detect optimization mode programmatically - Expert Advisors - MQL5 programming forum (2020.05.15)

Your point 1 is really the worst advice you ever gave on this forum.

Actually it's almost the reverse which is true, you should be doing almost all different. Why ? for optimization (speed) reasons.

 
Dua Yong Rew:
is there a function that can detect that I'm doing a backtesting?

Ontester() I believe it is called. It shows up in a textbox when you open a new project. It will have a checkbox asking if you want the code pre-added to your template (image attached)

Files:
tester.jpg  464 kb
 
Bodhi Mantra #:

Ontester() I believe it is called. It shows up in a textbox when you open a new project. It will have a checkbox asking if you want the code pre-added to your template (image attached)

Not the one I'm looking for but thanks
 
Alain Verleyen #:

Your point 1 is really the worst advice you ever gave on this forum.

Actually it's almost the reverse which is true, you should be doing almost all different. Why ? for optimization (speed) reasons.

The Optimizer will change the parameters, the code follows them. My comment is nothing about that.

If the code tests for optimization and does something different, the results are now meaningless for live trading.

 
William Roeder #:

The Optimizer will change the parameters, the code follows them. My comment is nothing about that.

If the code tests for optimization and does something different, the results are now meaningless for live trading.

Not sure what you are saying here.

I am talking about optimization of the code (I wrote "for optimization (speed)" which maybe is not clear enough), not about Strategy Tester optimization. Yes you have to take care if your code is executed on a live chart or within the Strategy Tester, just one example :

On your live chart you have a loop on Positions to count open positions, it's mandatory as you can have several EAs running, manual intervention... but a loop repeated millions of times (supposing you test on real ticks) is costly. A code running on the Strategy Tester could just use a counter to increment/decrement when a position is open/close. It's speed optimization which needs to "detect that I'm doing a backtesting? "

There are a lot of speed optimizations that can be done when running the Strategy Tester, of course in the end the results must be the same than the live version. But it can make the difference between a backtest that take 1 hour and 1 that take some seconds.

Reason: