Skipping redundant optimisation parameters

Hello,

I have a strategy in which I have a few filters I am using, namely OsMA, Stochastic, RSI and CCI. Apart from the parameters of each indicator, I have on and off inputs for each one of them:


input bool use_osma= true;
input bool use_sto = true;
input bool use_rsi = true;
input bool use_cci = true;

input int fOs=120;
input int sOs=70;
input int sigOs=45;

input int K=19;
input int D=7;
input int S=11;

input int RSIp=2;

input int CCIp=4;

Now when I’m trying to optimise the strategy, I want to also check which combination of filters works best. But the problem is that when one of the filters is turned off( let’s say for example it’s the OsMA that is off), the optimisation still does tests with different settings for the OsMA, wasting unnecessary testing time.

So is there a way to skip these different tests of an indicator’s settings, when that indicator is turned off?

I can’t think of a way to do it with INIT_PARAMETERS_INCORRECT.

Thanks

Maybe something like this?

#define OSMA_DEFAULT_F 120
#define OSMA_DEFAULT_S 70
#define OSMA_DEFAULT_SIG 45

input bool use_osma= true;
input int fOs = OSMA_DEFAULT_F;
input int sOs = OSMA_DEFAULT_S;
input int sigOs = OSMA_DEFAULT_SIG;
int OnInit()
{
   bool osma_skip = (!use_osma 
      && (fOs != OSMA_DEFAULT_F 
         || sOs != OSMA_DEFAULT_S
         || sigOs != OSMA_DEFAULT_SIG
      ) 
   );
   if(osma_skip)
      return INIT_PARAMETERS_INCORRECT;
   return INIT_SUCCEEDED;
}
1 Like

The approach proposed by tlawsi will certainly work in theory.

However please note if you want to use the Genetic algorithm, that you can’t reject too much parameters this way as it will screw up the algorithm.

Excellent point. Thank you.

The approach is correct.

If an input is irrelevant, reject all passes where the value(s) is/are not the default ones.

The optimizer will quickly decide which options are most important and then optimize only those relevant inputs.

Agree. I use ExpertRemove() onInit for incompatible parameters, optimizer runs no problem with the rest.