Optimization: How do you do avoid passes of meaningless sets (Best Practice)?

 

Hi,

I want to optimize various MAs. only the iMA() 'knows' different methods (sma, ema, smma, lwma) the others (iDEMA, iTEMA, iAMA) don't.

So any setup with MaMethod != iMA that varies sma, ema, smma, lwma are meaningless like:

enum €ChooseMA {  // 
   €iMA,     // norm MA: maPer, maPrc
   €iDEMA,   // DEMA dmaPer, dmaPrc
   €iFrAMA,  // FracEMA: fmaPer, famPrc
   €iTEMA,   // tripEMA tmaPer, tmaPrc
   €iAMA,    // Adap. MA: amaPer,amaFast,amaSlow,amaPrc
};

input €ChooseMA            MA          = €iTEMA;         // Type of MA
input uint                 MaPeriod    = 33;             // Periods for Ma
input ENUM_MA_METHOD       Meth        = MODE_SMMA;      // Method of averaging
input ENUM_APPLIED_PRICE   Prc         = PRICE_CLOSE;
 
...
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit() {
   if ( MA != €iMA && Meth != MODE_SMMA ){
      return(INIT_PARAMETERS_INCORRECT);
   }
..
}

Now if the Optimizer wants to run e.g.:

  1. MA=€iTEMA, MaPeriod=33,Meth=sma
  2. MA=€iTEMA, MaPeriod=33,Meth=ema
  3. MA=€iTEMA, MaPeriod=33,Meth=smma
  4. MA=€iTEMA, MaPeriod=33,Meth=lwma

They all will have the same optimization result and can be avoided - except one (in my example is #3).

From my experience in MT4 I know that this way the passes are not executed by the Mt4 Strategy Tester but despite that its genetic optimizer counts them as passes which effects the maximal number of passes it runs and this is one of it stop criteria.

:(

Anyone with experiences here and/or another way to do it.

I have read that MT5 offers TesterInit, TesterDeinit and TesterPass but this would mean (you should use the three instead of Init, DeInit and OnTick)  I have to write en EA just for testing doubling the code??

MT5 shows the same problem! :(

All the setups of the initial parameters that were skipped by "return(INIT_PARAMETERS_INCORRECT) are listed in the table of the Results of the Optimization. :(

 
Carl Schreiber:

From my experience in MT4 I know that this way the passes are not executed by the Mt4 Strategy Tester but despite that its genetic optimizer counts them as passes which effects the maximal number of passes it runs and this is one of it stop criteria.

:(

Anyone with experiences here and/or another way to do it.

I have read that MT5 offers TesterInit, TesterDeinit and TesterPass but this would mean (you should use the three instead of Init, DeInit and OnTick)  I have to write en EA just for testing doubling the code??

MT5 shows the same problem! :(

All the setups of the initial parameters that were skipped by "return(INIT_PARAMETERS_INCORRECT) are listed in the table of the Results of the Optimization. :(

I think this is by design. Probably someone from MQ could discuss that. I don't think we can exclude such passes from count neither in MT4 nor MT5.

As for TesterInit, TesterDeinit, TesterPass they are not duplicates of OnInit, OnDeInit, etc. First ones are executed in the terminal - single point managing the process, and the second ones are executed in the tester agents. Probably you did not read the docs thoroughly.

 
Stanislav Korotky:

I think this is by design. Probably someone from MQ could discuss that. I don't think we can exclude such passes from count neither in MT4 nor MT5.

As for TesterInit, TesterDeinit, TesterPass they are not duplicates of OnInit, OnDeInit, etc. First ones are executed in the terminal - single point managing the process, and the second ones are executed in the tester agents. Probably you did not read the docs thoroughly.

Well the view point of writing an EA I get the impression after reading in the reference:

Such an event receives the TesterInit, TesterDeinit and TesterPass events, but not Init, Deinit and NewTick ones. Accordingly, all necessary logic for processing the results of each pass during optimization should be implemented in the OnTesterInit (), OnTesterDeinit () and OnTesterPass () handlers.

that an EA which naturally needs OnInit() OnDeInit() and OnTick() where alkl the logic is implemented additionally needs TesterInit, TesterDeinit, TesterPass!

Or do you have EAs without OnInit() OnDeInit() and OnTick()?

 
Carl Schreiber:

Well the view point of writing an EA I get the impression after reading in the reference:

that an EA which naturally needs OnInit() OnDeInit() and OnTick() where alkl the logic is implemented additionally needs TesterInit, TesterDeinit, TesterPass!

Or do you have EAs without OnInit() OnDeInit() and OnTick()?

With TesterInit, TesterDeinit, TesterPass you could manage the optimization results to process them and for example write them in your own file or database. It's like if you had a second EA (running in the Terminal) dedicated to manage your optimization. Try to read this article for example if you want to understand them better.

Your way to use INIT_PARAMETERS_INCORRECT is the good one, but with the drawback you noticed. Also the % of parameters combination excluded should be low if you want to use the Genetic Algorithm, as otherwise the results could be inaccurate.

EDIT: In my opinion your best option in such case is to optimize MA separately.
 
Alain Verleyen:
EDIT: In my opinion your best option in such case is to optimize MA separately.

Why do I have a PC when I still have to do the things manually?

 
Carl Schreiber:

Why do I have a PC when I still have to do the things manually?

Who said that ? Code it.
 

OnInit is required. All other handlers are optional.

To trade in EA you should normally implement OnTick and/or OnTimer and/or OnBookEvent, but not necessarily (for any of them). Other possible events are not even mentioned here as offtopic.

Use OnTester for custom processing of a single pass/test results.

All of above run in the tester agents (can be local or remote). [NB: book events are not generated in the tester so far]

OnTesterInit, OnTesterPass, OnTesterDeinit are intended for custom processing of optimization process. Of course they are optional as well. They run in the terminal itself (locally).

Of course, when you trade online all events are executed in the terminal, except for all tester-related events which make no sense.

According to some info on the russian forum, if the number of passes with incorrect parameters are less than 25%, this does not affect genetics in any negative way. If you have more cases with incorrect parameters, you should redesign your input parameters in such a way, that incorrect values are omitted in the input space (make required convertions in your MQL5 code). I think this can be considered as a [partially] official answer of MQ since they are definitely know about the same discussion on the russian forum.

Reason: