Getting pass number while EA is going through optimization in strategytester?

 

Hello People

I am just curious if EA can commnuicate with strategytester duing its optimizaiton process.

I can see that with  "ParameterGetRange" and "ParameterSetRange" you can freely get and set optimizaiton parameters on strategy tester from your EA.

However I have not found the ways of getting  each pass number during optimization from EA. Does EA have an access to individual pass number and other statistics generated from strategyteser during runtime (not after optimziation is completed but during optimizaiton) ? 

Really appreciated if you could share your wisdom.

Kind regards.

 

 

 
Please see if this article can help you ?
MQL5 Cookbook: Saving Optimization Results of an Expert Advisor Based on Specified Criteria
MQL5 Cookbook: Saving Optimization Results of an Expert Advisor Based on Specified Criteria
  • 2013.10.15
  • Anatoli Kazharski
  • www.mql5.com
We continue the series of articles on MQL5 programming. This time we will see how to get results of each optimization pass right during the Expert Advisor parameter optimization. The implementation will be done so as to ensure that if the conditions specified in the external parameters are met, the corresponding pass values will be written to a file. In addition to test values, we will also save the parameters that brought about such results.
 
angevoyageur:
Please see if this article can help you ?

Thanks for direction.

All I am trying to do is to simply get pass number.

Tried this code but nothing was printed.

int pass = 0;

void OnTesterPass()
{
    pass = pass + 1;
    printf("pass = %d", pass);
}

But it did not work.

Still don't get the concept of FrameAdd and FrameNext function. I think this might be much more complicated than we think as we have deal with multiple thread from the strategy tester. :)

Regards.

 
FinanceEngineer:

Thanks for direction.

All I am trying to do is to simply get pass number.

Tried this code but nothing was printed.

But it did not work.

Still don't get the concept of FrameAdd and FrameNext function. I think this might be much more complicated than we think as we have deal with multiple thread from the strategy tester. :)

Regards.

Why do you need the pass number ?
 
angevoyageur:
Why do you need the pass number ?

Yes, I wanted to record pass number on the file, which created before optimization, as each pass in optimization is completed.

So I can write some other information on the file together.

Pass will tell me at which time and from what parameter setting the information was written. 

Kind regards.

 
FinanceEngineer:

Yes, I wanted to record pass number on the file, which created before optimization, as each pass in optimization is completed.

So I can write some other information on the file together.

Pass will tell me at which time and from what parameter setting the information was written. 

Kind regards.

You should use  https://www.mql5.com/en/docs/optimization_frames/framenext function in OnTesterPass event handler - see the documentation on events:  https://www.mql5.com/en/docs/basis/function/events.
Documentation on MQL5: Working with Optimization Results / FrameNext
Documentation on MQL5: Working with Optimization Results / FrameNext
  • www.mql5.com
Working with Optimization Results / FrameNext - Reference on algorithmic/automated trading language for MetaTrader 5
 
marketeer:
You should use  https://www.mql5.com/en/docs/optimization_frames/framenext function in OnTesterPass event handler - see the documentation on events:  https://www.mql5.com/en/docs/basis/function/events.

Thanks a lot. I will give a go. I never try this functon before and still try to get my head around with this concept of frame.

Got to have sometime to read. :)

Kind regards.

 

This thread is a bit old, but someone may still want to get the pass number (or other values) from an optimization, especially from an external automation script, without using frames.

The following discussion considers MT5—it may work with MT4, but caveat emptor.

In a configuration .ini file, you can specify a "Report" parameter. This specifies where the optimization report will be saved relative to the platform_installation_directory.

The saved file is a .xml file, which can be opened by any spreadsheet software (e.g. LibreOffice Calc, probably with others).

The "pass" number is saved within this XML along with other tasty values calculated during the optimization.

Perhaps the most important entry(ies) for me are the input parameter values for the optimization. Thus, if I want to find the max stop loss (MAX_SL) that produces the highest net profit and best Sharpe ratio, I can find it in here.

So, simply read the file contents into your software using an XML parser then search for the row/value(s) you want. Easy peasy.

 
All I want to do is save the node parameters of an AI training session based on say best max profit or other variable... it should be a one liner instead it seems to be a framing nightmare!
 
Anthony Eric Gillon Dawson:
All I want to do is save the node parameters of an AI training session based on say best max profit or other variable... it should be a one liner instead it seems to be a framing nightmare!

If it was single core only a one liner would do it. Otherwise not.

 
Anthony Eric Gillon Dawson #:
All I want to do is save the node parameters of an AI training session based on say best max profit or other variable... it should be a one liner instead it seems to be a framing nightmare!

This is about the same reason I need it. I already parse the xml and html reports. However, now I need to store the results in a sqllite database, which content is read by an external program.

So, the only way I can think of to solve this is to construct a custom identifying unique value yourself. For example a string with your parameter names and values, or a hash. When you store it in json format, you can interpret the identifier in external programs.

And remember that you keep it's signature consistent and normalize the parameter values, their order and number of parameters. Because "{inp_myParamx = 0.0, inp_myParamy = "value"}" is not the same as "{inp_myParamx = 0.000, inp_myParamy = "value"}" or  "{inp_myParamy = "value", inp_myParamx = 0.000, inp_myParamz = -1}" .

Reason: