loop in Optimizer

 
Hello
does anyone know a way to do an infinite loop with optimizer of MT4/5?
Inside the loop, at the end of each optimization, I must be able to set automatically the new parameters optimized into the EA that is running.
In each loop I must be able to pass parameters that would always be the same except for the start date of the data.
There is a kind of command line programmed by windows shell commands?
 
Your requirements are not clear. Do you mean "walk forward" optimization? Try searching for this term.
 
Stanislav Korotky:
Your requirements are not clear. Do you mean "walk forward" optimization? Try searching for this term.

Hi Stanislav

I do not mean "walk forward" optimization

I have done an EA with 7 parameters, my need is to automatize the optimization run + setting of parameter on the running EA using best 2 results.

This automation must be execute in an infinite loop so that the parameters are always set to best performance get during last optimization.

 

 
Try this article for beginning. Also search for automatic (or batch) testing and optimization, you'll get many results such as this thread, for example.
 
Stanislav Korotky:
Try this article for beginning. Also search for automatic (or batch) testing and optimization, you'll get many results such as this thread, for example.

thanks

I used the TestReport field and the report created do not contains the parameters list column (inputs) , is there a way to include this column?

 
Pier Gaetano Novara:

I used the TestReport field and the report created do not contains the parameters list column (inputs) , is there a way to include this column?

The TestReport is just a name of file with results, it does not change MetaTrader output format. Do you want to parse html (input parameters are included as pass number hint)? Or maybe you prefer to accumulate passes on your own and save all required data in a custom file? Please provide more details.
 
Stanislav Korotky:
The TestReport is just a name of file with results, it does not change MetaTrader output format. Do you want to parse html (input parameters are included as pass number hint)? Or maybe you prefer to accumulate passes on your own and save all required data in a custom file? Please provide more details.

Hi Stanislav

what I mean is that the report generated in html format do not contain the column inputs that is in the tester GUI (see attachment)

Am I doing something wrong?

this is the ini file content:

; start strategy tester
  TestExpert=Due
  TestExpertParameters=due.set
  TestSymbol=USDCHFm
  TestPeriod=M5
  TestModel=2
  TestSpread=0
  TestOptimization=true
  TestDateEnable=false
  TestFromDate=
  TestToDate=
  TestReport=DueReport
  TestReplaceReport=true
  TestShutdownTerminal=false

Files:
DueREport.zip  214 kb
 
Pier Gaetano Novara:

what I mean is that the report generated in html format do not contain the column inputs that is in the tester GUI (see attachment)

As I said, the html-report does contain input parameters in pass number hint. You can see them by hovering mouse over pass number.
 
Stanislav Korotky:
As I said, the html-report does contain input parameters in pass number hint. You can see them by hovering mouse over pass number.

Thanks Stanislav,

so this is not an error but the normal behavior, for me is quite strange, what is the sense of running optimizer if I can not export the parameters values optimized (that in my case I will read from EA to set the new parameters values)?

Anyway thanks again for the info.

 
You should decide for yourself, how would you "export" parameters from the resulting html-report if it would contain parameters in a separate column? Would you parse html to read this column? If yes, then you can as well parse existing html and export parameters from the hints. If no, you could prefer to write optimization results into your custom file, such as csv (look at OnTester, OnTesterInit, OnTesterPass events).
 
Stanislav Korotky:
You should decide for yourself, how would you "export" parameters from the resulting html-report if it would contain parameters in a separate column? Would you parse html to read this column? If yes, then you can as well parse existing html and export parameters from the hints. If no, you could prefer to write optimization results into your custom file, such as csv (look at OnTester, OnTesterInit, OnTesterPass events).

Hi Stanislav

I investigated and I tried this code

void OnTesterInit()
 {
 optimizedBalance=0;
 }
 
double OnTester()
 {
 ResetLastError();
 filehandle=FileOpen("testr.txt",FILE_WRITE,";");
 if(filehandle==INVALID_HANDLE)
   Alert("Operation FileOpen failed, error ",GetLastError());
 else
  if (AccountBalance()>optimizedBalance)
   {
   optimizedBalance=AccountBalance();
   FileWrite(filehandle,DoubleToString(AccountBalance(),2)+" "+... parameters);

   FileFlush(filehandle);   FileClose(filehandle);

  }
 return(1);
 }

But is not working because the file created has not the raw with max AccountBalance

Reason: