How to increase the maximum number of passes in optimization?

 

I notice I can test up to 400 passes only.  How can I increase this?  And what does the 1280 below means?  I know '3' means the current pass number and '630' is the total passes that are generated based on the optimization parameters I've set.  Right now I just cannot get passed more than 400 passes.

 Many thanks! 

 
lingwuchung:

I notice I can test up to 400 passes only.  How can I increase this?  And what does the 1280 below means?  I know '3' means the current pass number and '630' is the total passes that are generated based on the optimization parameters I've set.  Right now I just cannot get passed more than 400 passes.

Look what I found using Google  https://www.mql5.com/en/forum/138462
 
3/1280 (630)

If you don't use Genetic there are 1280 unique combinations.

If you use Genetic it's estimating 630 combinations. Actual combinations depends on when it stops getting improving results.

I can test up to 400 passes only.  How can I increase this
Improve your algorithm.
 

Hello,

I was wondering if I can do the opposite. I want to reduce the final number of passes because at the end, the results all look very similar. For example, if I have 3/10496, I want to stop the optimization process when it reaches 2000 passes, or to return negative values for these passes.

Do you know if it is possible?


 
Agnello Hupp:

I was wondering if I can do the opposite. I want to reduce the final number of passes because at the end, the results all look very similar. For example, if I have 3/10496, I want to stop the optimization process when it reaches 2000 passes, or to return negative values for these passes.

Enable Genetic Testing:

Alternatively, add extra code to the OnInit() event handler to analyse or validate the parameters and for those combinations that you know will not provide useful testing, immediately return from the it with the error code. This will still produce a report output with everything set to zero, but no time will be spend actually testing that combination.

int OnInit()
{
   // Check Parameters for Invalid or Unwanted Combinations
   if( ... check for invalid parameters ... )
      return( INIT_PARAMETERS_INCORRECT );

   // Continue if all conditions are met
   return( INIT_SUCCEEDED );
}
 
Fernando Carreiro: Alternatively, add extra code to the OnInit() event handler to analyse or validate the parameters and for those combinations that you know will not provide useful testing,

In addition to Fernando Carreiro's testing invalid parameters, e.g. count <= 0, and invalid combinations of parameters, e.g. begin >= end, if a parameter controls the use of others, reject any that is not the default. E.g. if you have isEnabled, A=1, B=2, and C=3, if not enabled, only allow default/initial values for the others. I.e. only one test with not enabled, A, B, C values are irrelevant.

 

Thank you for the comment. But I'm trying to do something different from what you suggest. I'm happy with the range of inputs I have. I just want prevent the GA from doing to much passes, specially at the end. Because I use the Forward analysis, and from personal experience the passes coming from optimization that are, let's say, bigger than 2k, are not good ones. 

So, I'm trying to count the number of passes and when it reaches 2000, I want it to return only bad values.

The GetOnTesterValue is a custom optimization function and works great. But I don't understand why it never enters the > 2000 condition and never returns -100.

Any ideias?

When I print the "mGlobalVar.getCount()" valeu on "OnTesterPass" function I can see that values are being increased by 1. But on the "OnTester" function, where I should calculate the custom values, it returns 0 always.

Thank you


void OnTesterInit() {
   Print("Optimization Started");
}

// OnTester function uses net profit to optimize systems
double OnTester() {
    FrameAdd("Statistics",1,0,stat_values);
    if(exportResults) tot_profit.ExportResultsToFile(stratName);
    if(mGlobalVar.getCount() > 2000) return(-100);
    return(tot_profit.GetOnTesterValue());
}

void OnTesterPass() {

    string name ="";  // Public name/frame label
    ulong  pass =0;   // Number of the optimization pass at which the frame is added
    long   id   =0;   // Public id of the frame
    double val  =0.0; // Single numerical value of the frame
    //---
    FrameNext(pass,name,id,val,stat_values);
    //---
    Print(__FUNCTION__,"(): pass: "+mGlobalVar.getCount());
    passes++;
    mGlobalVar.Increase();
}

void OnTesterDeinit() {
   Print("Optimization Finished");
}
 
Agnello Hupp:

Thank you for the comment. But I'm trying to do something different from what you suggest. I'm happy with the range of inputs I have. I just want prevent the GA from doing to much passes, specially at the end. Because I use the Forward analysis, and from personal experience the passes coming from optimization that are, let's say, bigger than 2k, are not good ones. 

So, I'm trying to count the number of passes and when it reaches 2000, I want it to return only bad values.

The GetOnTesterValue is a custom optimization function and works great. But I don't understand why it never enters the > 2000 condition and never returns -100.

Any ideias?

When I print the "mGlobalVar.getCount()" valeu on "OnTesterPass" function I can see that values are being increased by 1. But on the "OnTester" function, where I should calculate the custom values, it returns 0 always.
That does not make any sense. Are you using the "Slow complete algorithm" or the "Fast genetic based algorithm"?

Sorry, but I don't have experience with using the Frame functions. All I can do is offer a few links that might help:

 

Thank you! I will take a look at them

 
Agnello Hupp:

Thank you! I will take a look at them


I'm not sure why this question appeared here because it should belong to MT5 sections, because the mentioned event handlers are available in MT5 only.

As for your specific problem, it originates from the fact that you did not notice that OnTesterPass is executed in the terminal, whereas OnTester - in the agents. So you have different instances of the counter.

What you want is to pass the central instance of the counter from the terminal to the agents. Unfortunately this is not possible. All you can do is to skip further execution of all tasks in the current batch (with several passes) on specific agent - for this purpose you may create a file, when further passes do not make sense, and check for this file existence in OnInit - if it exists - just return INIT_FAILED. But you can not stop new batches by this method. If you use only local agents, you may create the file in the common folder, then it will affect all agents on this PC.

You may find in depth discussion in the Russian forum - this thread:

Reason: