Only make necessary backtests in optimization

 

Hello,

I'd like to know, when I make a complete optimisation backtest of my EA, if it is possible to ignore useless tests in order to save time.

For example, if my code is the following:

[code]

if(use_rsi)

     {

   actualRSI = iRSI(Symbol(),rsi_timeframe,rsi_period,rsi_applied_price,rsi_shift);

   ....

     {

[/code]

If in the backtests Inputs I have:

 -  use_rsi (true/false)

 -  rsi_timeframe (H1/H4/D1)

 -  rsi_period (14/20/25/30)


I'd like to have only 1 backtest when  use_rsi == false instead of 12 in this case (rsi_timeframe = H1 /  rsi_period = 14, rsi_timeframe = H1 /  rsi_period = 20, rsi_timeframe = H1 /  rsi_period = 25...).

Indeed, if use_rsi == false, backtests results will be the same whatever the values of rsi_timeframe and rsi_period are.

Is there a method in MQL4 or MQL5 or a way to code in order to avoid these useless tests?

 

Forum on trading, automated trading systems and testing trading strategies

Skipping some input in strategy

Fernando Carreiro, 2022.10.03 15:25

In the OnInit() event handler, test for the valid combination of parameters and if they are not valid, return the "INIT_PARAMETERS_INCORRECT" result.

The optimiser will then proceed on to the next iteration of the process and set all the results for that pass to zeros.

EDIT: You can also set special combinations that are only valid (or not valid) when running under the optimiser. Verify this condition with "MQL_OPTIMIZATION".

 

Here is an example from the CodeBase ... Have a look at the OnInit() handler ...

Code Base

MARE5.1

Vladimir Karputov, 2017.03.02 11:50

The MARE5.1 Expert Advisor is very easy to use. It uses the values of two Moving Averages (SMA) at the close of 0th, 2nd and 5th bar. The EA is configured to work on the M1 timeframe.
 

Hi Fernando and William!

Thank you very much for this quick reply, it will help me a lot!

Reason: