Not for MT developers! What to replace INIT_PARAMETERS_INCORRECT with ? - page 11

 
Сергей Таболин:

An idea came up to sift out "invalid" parameters during genetic optimization in OnTester():

It turns out that without interfering with genetics the results of INIT_PARAMETERS_INCORRECT may not be seen.

But here we have another question: can we get "deep minus" on profit in this case?

this is a very slow method. We are spending resources calculating the whole pass.

 
Mikhail Mitin:

is a very slow method. We're wasting resources on miscalculating the entire aisle.

Of two evils...

 
Mikhail Mitin:

is a very slow method. We are wasting resources calculating the whole pass.

EnterINIT_PARAMETERS_INCORRECT_ONTESTER - rollover to OnTester.

 

How I solved this problem (several variants):

  • A separate parameter is created, and other values are substituted depending on its value (described in a couple of posts above). Optimization goes only for this parameter
  • there's also 1 way out of this situation, but it's not easy to implement:
    1. created csv file, in which was the enumeration of only necessary parameters
    2. i read the file in the OnInit, read values from the file and give them to the parameters (read files with the flag Shared access)
    3. optimized only 1 parameter (line number in the csv file)
  • wrote an algorithm for generating an mqh file from a csv file (similar to the points above, but faster) and connected it to the Expert Advisor.

 
Mikhail Mitin:

How I solved this problem (several variants):

  • A separate parameter is created, and other values are substituted depending on its value (described in a couple of posts above). Optimization goes only for this parameter
  • there's also 1 way out of this situation, but it's not easy to implement:
    1. created csv file, in which was the enumeration of only necessary parameters
    2. i read the file in the OnInit, read values from the file and give them to the parameters (read files with the flag Shared access)
    3. optimized only 1 parameter (line number in the csv file)
  • wrote an algorithm for generating an mqh file from a csv file (similar to the points above, but faster) and connected it to the Expert Advisor.

And how does this allow you to implement a genetic algorithm, if you have only one variable?

 

It's dawned on me! ))))

From the OnInit lines

   if((MQLInfoInteger(MQL_OPTIMIZATION) || MQLInfoInteger(MQL_TESTER)) && period_HMA7C == 0 && move_profit)                  return(INIT_PARAMETERS_INCORRECT);
   if((MQLInfoInteger(MQL_OPTIMIZATION) || MQLInfoInteger(MQL_TESTER)) && period_HMA7C == 0 && move_stop)                    return(INIT_PARAMETERS_INCORRECT);
   if((MQLInfoInteger(MQL_OPTIMIZATION) || MQLInfoInteger(MQL_TESTER)) && period_HMA7C == 0 && shift_correction_HMA7C != 5)  return(INIT_PARAMETERS_INCORRECT);

moved to.

void OnTick()
{
//--- пропустить бесполезные проходы оптимизации
   if((MQLInfoInteger(MQL_OPTIMIZATION) || MQLInfoInteger(MQL_TESTER)) && period_HMA7C == 0 && move_profit)                                 ExpertRemove();
   if((MQLInfoInteger(MQL_OPTIMIZATION) || MQLInfoInteger(MQL_TESTER)) && period_HMA7C == 0 && move_stop)                                   ExpertRemove();
   if((MQLInfoInteger(MQL_OPTIMIZATION) || MQLInfoInteger(MQL_TESTER)) && period_HMA7C == 0 && shift_correction_HMA7C != 5)                 ExpertRemove();

Genetics does not interfere, andPARAMETERS_INCORRECT is not calculated. )))

 
Сергей Таболин:

It's dawned on me! ))))

From the OnInit lines

moved to.

Genetics does not interfere, andPARAMETERS_INCORRECT is not calculated. )))

Interesting solution. And how, genetics goes successfully, doesn't get bogged down in one descendant?

 
Aleksey Vyazmikin:

That's an interesting solution. And how, is the genetics going well, not getting bogged down in one offspring?

It's okay. It's not failing. ))) At least not yet. Somewhere I had an owl with a lot of invalid parameters. I'll have to run optimization on it and see.

The idea of porting is that genetics stumbles exactly at initialization. But if check is moved to OnTick , then initialization goes well, test starts, ends immediately and genetics gets result of pass to zero.

 
Сергей Таболин:

It's OK. It's not going down. ))) At least not yet. Somewhere I had an owl with a lot of invalid parameters. I'll have to run optimization on it and see.

The idea of porting lies in the fact that genetics stumbles exactly at initialization. But if check is moved to OnTick , then initialization goes well, test starts and ends right away and genetics obtains zero result.

It's good that it doesn't fail. The essence of the code is clear, but I would add execution only once, especially if there are many conditions for early exit.

 
Aleksey Vyazmikin:

It's good that it doesn't get bogged down. The gist of the code is clear, but I would only add execution once, especially if there are many conditions for early exit.

Optimisation on that owl I was talking about is going well. )))

Good idea. We need to add a check flag.