Conditional Optimisation Parameters - page 2

 
cyberdeth #:

That's what I'm looking for. But the problem is that the optimisation passes are done at startup, so you can get potentially billions of passes that shouldn't be run. I would love to find a way to filter out/update the bad passes before the testing starts. it's not a case of the lookup table to filter out unwanted combinations, it's a problem where duplicated results are returned for multiple passes when the critreria for the pass shouldn't be considered. I get that you are trying to help, and I've tried all the avenues that I can think of. if i could find a way to read in a lookup table with the combinations, then that would be ideal. But the current functionality of the  ParameterSetRange, does not allow that. Unless there's another method i can use to manually set the parameters i want to test.

I think this usecase falls outside the current capability of metatrader. Let me be clear, i'm not saying Metatrader is bad, it's just this usecase, where I want to remove the ability for the optimising parameters to be running passes when it's going to have no material impact on the results, is missing.

Another simple way, is to simple test the combinations in the OnInit() function and if they are to be discarded, then simply return INIT_PARAMETERS_INCORRECT, and that pass will not be run.

INIT_PARAMETERS_INCORRECT

Designed to denote an incorrect set of input parameters by a programmer. In the general optimization table, the result string with this return code is highlighted in red.

A test for such a set of EA inputs is not performed. The agent is ready to receive a new task.

When this value is received, the strategy tester does not pass this task to other agents for repeated execution.

 
Fernando Carreiro #:

Another simple way, is to simple test the combinations in the OnInit() function and if they are to be discarded, then simply return INIT_PARAMETERS_INCORRECT, and that pass will not be run.

INIT_PARAMETERS_INCORRECT

Designed to denote an incorrect set of input parameters by a programmer. In the general optimization table, the result string with this return code is highlighted in red.

A test for such a set of EA inputs is not performed. The agent is ready to receive a new task.

When this value is received, the strategy tester does not pass this task to other agents for repeated execution.

yeah I do use that, but that's only if very specific conditions for failure are met. I still want tests to run where the data is valid, but i don't want it to run if the outcome has no effect on disabled parameters. Your previous example is perfect.

 
cyberdeth #: yeah I do use that, but that's only if very specific conditions for failure are met. I still want tests to run where the data is valid, but i don't want it to run if the outcome has no effect on disabled parameters. Your previous example is perfect.

You are overcomplicating it again. This method is still useful for that.

For example, assume a MA cross with a fast and slow period where I optimise both periods from 1 to 200. I use this method to filter out all combinations where the "slow" period is not greater than the "fast" period, which drastically reduces the number of combinations tested.

 

Not really, the case you mention does work, however, assume you have 3 indicators:

MACD

MA Trend

MA Cross

Just because the criteria for the MACD is invalid, does not mean I don't want to still run the test when the MA Trend and MA Cross criteria is valid. Furthermore, according to the documentation, when ~500 passes return 0 or has initialisation failures, then the entire optimisation is stopped.

 
cyberdeth #:

Not really, the case you mention does work, however, assume you have 3 indicators:

MACD

MA Trend

MA Cross

Just because the criteria for the MACD is invalid, does not mean I don't want to still run the test when the MA Trend and MA Cross criteria is valid. Furthermore, according to the documentation, when ~500 passes return 0 or has initialisation failures, then the entire optimisation is stopped.

Fair enough, then use the lookup method, especially if you plan to use the faster genetic optimisations.

I have never had need to discard so many, but out of curiosity where in the documentation is that ~500 mentioned?

 

By the way, there is also another method using the OnTesterInit() to auto generate parameter ranges. See the following ...

MQL5 Book: Trading automation / Testing and optimization of Expert Advisors / Auto-tuning: ParameterGetRange and ParameterSetRange
MQL5 Book: Trading automation / Testing and optimization of Expert Advisors / Auto-tuning: ParameterGetRange and ParameterSetRange
MQL5 Book: Trading automation / Testing and optimization of Expert Advisors / Auto-tuning: ParameterGetRange and ParameterSetRange
  • www.mql5.com
In the previous section, we learned how to pass an optimization criterion to the tester. However, we missed one important point. If you look into...
 
Fernando Carreiro #:

By the way, there is also another method using the OnTesterInit() to auto generate parameter ranges. See the following ...

MQL5 Book: Trading automation / Testing and optimization of Expert Advisors / Auto-tuning: ParameterGetRange and ParameterSetRange

The 500 number was an arbitrary number i've seen when running optimisations, but this forum references that too many invalid parameters cause failures  New Version of MetaTrader 5 Platform build 1860: Functions for Working with Bars in MQL5 and Improvements in the Strategy Tester - General Discussion - MQL5 Algo Traders Forum - Page 14. WRT the ParameterSetRange, i have tried that and you will see that i have referenced it in the start of my thread. It doesn't quite work because the passes are generated onTestInit, unless my understanding is incorrect and that it generates it on every pass. but i could not get the behaviour i wanted. maybe i'll revisit it.

Новая версия платформы MetaTrader 5 build 1860: Функции для работы с барами в MQL5 и улучшения в тестере стратегий
Новая версия платформы MetaTrader 5 build 1860: Функции для работы с барами в MQL5 и улучшения в тестере стратегий
  • 2018.06.25
  • Aleksey Vyazmikin
  • www.mql5.com
Новая версия платформы MetaTrader 5 build 1860: Функции для работы с барами в MQL5 и улучшения в тестере стратегий15 июня 2018 года будет опубликов...
 
Fernando Carreiro #:

By the way, there is also another method using the OnTesterInit() to auto generate parameter ranges. See the following ...

MQL5 Book: Trading automation / Testing and optimization of Expert Advisors / Auto-tuning: ParameterGetRange and ParameterSetRange

woohoo i got the params working. it's doing what i want now. thanks all.

 
cyberdeth #:

woohoo i got the params working. it's doing what i want now. thanks all.

spoke too soon. it doesn't work as intended.

void OnTesterInit() {
      ENUM_MA_PERIOD signalPeriod = MAP_0;
      bool useSignal = false;
      long value, start, step, stop;
      ParameterSetRange("InpMASignalPeriod", false, 0, 0, 0, 0);
      if (ParameterGetRange("InpUseMASignal", useSignal, value, start, step, stop)) {
         if (useSignal) {
            ParameterSetRange("InpMASignalPeriod", true, signalPeriod, MAP_5, 1, MAP_200);
         }
      }
}

int OnInit() {
        if (InpUseMASignal && InpMASignalPeriod != 0) {
                maSignal = new MASignal(_Period, InpMASignalPeriod);
                if (maSignal.initState == INIT_SUCCEEDED) {
                        validSignals[validSignalCount++] = SIGNALS_MA;
                }
   }
}

But I'm still getting:

instead of 0 where the signal is false. Furthermore when i start the genetic optimisation, in the journal I can only see the following being printed once.

// Initially set it to 0
2024.11.28 16:46:36.470 Tester  input parameter 'InpMASignalPeriod' set to: enable=false, value=0, start=0, step=0, stop=0

// For some reason it thinks the signal is enabled and setting the range and enabling it
2024.11.28 16:46:36.470 Tester  input parameter 'InpMASignalPeriod' set to: enable=true, value=0, start=5, step=1, stop=200

What I'm expecting is that the input param is calculated and set per pass. It would've been really helpful to have a method that's callable by the optimiser before a test, similar OnTester. Some like OnBeforeTester where you are able to set the input parameters.

 

I always approached similar scenarios using INIT_PARAMETERS_INCORRECT inside the OnInit and nothing else.

cyberdeth #:

So let's assume in my EA, I've got a section for 2 indicators:

Indicator A:
bool enabledA = true|false
int periodA = 1-200

indicator B:
bool enabledB  = true|false
int periodB = 1-200


int OnInit() {
   if( !enabledA && periodA!=1 ) return INIT_PARAMETERS_INCORRECT;
   if( !enabledB && periodB!=1 ) return INIT_PARAMETERS_INCORRECT;
   return INIT_SUCCEEDED;
}

In this case, when you have disabled indicator A, it will run only the first pass of your optimization, same for indicator B. But it's very similar of what Alain already suggested.