Automatic Optimization in MT5?

 

As frustrated as I have been teaching myself enough C++ to migrate my EA from MT4 to MT5, I really like the new platform...especially the Strategy Tester.  Remote agents ROCK!

But I have not been able to get the Automatic Optimization working.  Can anyone tell me if this works in MT5?  If so, could you please provide a sample [Tester] section of your configuration file?

Here is what I am using...

[Tester]
Expert=MACD Sample
ExpertParameters=MACD Sample.set
Symbol=EURUSD
Model=0
Optimization=1

I have tried with and without the "ExpertParameters" line.

Can someone tell me what I am missing?

TIA...ChuckM

 

We've made a  lot of changes and fixes.

Please, wait a little. I think you will be able to try using automatic optimization with the next build.

 
alexvd:

We've made a  lot of changes and fixes.

Please, wait a little. I think you will be able to try using automatic optimization with the next build.

Hi Alexvd,

Thanks for your reply. I am also quit interresed by this subject.

Can you please tell me if :

1. there is an availiable public roadmap plan (next realse date, build, bug fix ...).

2. Do you have also kind of documentation about automatic optimization. What is the concept/logic? How does it works?

Regards, 

 

Actually, after a lot of trial and error, I was able to get automatic optimization to work.  The problem with my [Tester] file was that I needed to specify the path to the EA:

[Tester]
Expert=Examples\MACD\MACD Sample.ex5
ExpertParameters=MACD Sample.set
Symbol=EURUSD
Model=0
Optimization=1

...and "ExpertParameters" is missing from the MT5 documentation...go to the MT4 Help Guide to see the description.

Now I'm running into problems with the code that will analyze the results.  It appears that Sleep() does not pause execution and the FileIsExist() function always returns true, if the file exists or not.

   while(true)
   {
      Sleep(60000);
      if (FileIsExist(FileReport1,FILE_COMMON)); 
         break;
   }
I'd also like to know when to expect the next release that will fix these issues.


TIA...ChuckM

 
ChuckM:

Actually, after a lot of trial and error, I was able to get automatic optimization to work.  The problem with my [Tester] file was that I needed to specify the path to the EA:

...and "ExpertParameters" is missing from the MT5 documentation...go to the MT4 Help Guide to see the description.

Have seen section "MetaTrader 5 Help → Getting Started → Terminal Start → Additional Parameters"?

[Tester]

Settings of the testing that is launched when the terminal is started:

  • Expert — name of an Expert Advisor that should be started for testing (optimization) when the terminal is started. If this parameter is absent the testing will not be launched.
  • Symbol — name of a symbol that will be used as a main symbol of testing. If this parameter is absent, the last selected symbols in the tester will be used.
  • Period — period of a chart for testing (any period from 21 available in the terminal). If this parameter is absent, the H1 period will be used.
  • Login — using this parameter, you can pass an account number that is allegedly used for testing to an Expert Advisor. The necessity of this parameter is built into an Expert Advisor in its source MQL5 code (using the AccountInfoInteger function).
  • Modelmode of tick generation (0 — "Every tick", 1 — "1 minute OHLC", 2 — "Open prices only"). If this parameter is not specified, the mode of generation of every tick will be used.
  • Optimization — enabling/disabling optimization and specification of its type (0 — optimization disabled, 1 — "Slow complete algorithm", 2 — "Fast genetic based algorithm", 3 — "All symbols selected in Market Watch").
  • FromDate — date of the beginning of the testing range in the YYYY.MM.DD format. If this parameter is absent, the last specified date in the corresponding field of the strategy tester will be used.
  • ToDate — date of the end of the testing range in the YYYY.MM.DD format. If this parameter is absent, the last specified date in the corresponding field of the strategy tester will be used.
  • Report — name of a file the testing report will be saved to. The file will be created in the client terminal directory. You can specify a path to save the file relatively to this directory, for example, \reports\tester.htm. If an extension is not specified in the file name, the ".htm" extension will be automatically used. If this parameter is absent, the testing report will not be saved as a file.
  • ReplaceReport — enabling/disabling the rewriting of the report file (0 — disabled, 1 — enabled). If the rewriting is disabled and a file with the same name already exists then the index number in square brackets will be added to the name of the file. For example, tester[1].htm. If this parameter is absent then "0" value will be used (rewriting disabled).
  • ShutdownTerminal — enabling/disabling shutting down of the client terminal at the end of testing (0 — disabled, 1 — enabled). If this parameter is absent, the "0" value is used (shutting down disabled). If the testing/optimization process is manually stopped by user, the value of this parameter is automatically reset to "0".
  • Deposit — amount of initial deposit for testing/optimization. The amount is specified in the deposit currency of the account. If this parameter is absent, the amount specified in the corresponding field of the strategy tester is used.
  • Leverage — leverage for testing/optimization. For example, if you specify 100 as the value of this field, then the 1:100 leverage is used. If this parameter is absent, the leverage specified in the corresponding field of the strategy tester is used.
  • Input parameters specified in an EA_name.set file located in the terminal_folder/tester/ directory are used for testing/optimization of an Expert Advisor. In such a file the last specified set of input parameters of an Expert Advisor is stored.
  • If there is no such file, then the default parameters specified in the code of the Expert Advisor will be used for testing. Optimization will be impossible.
  • In order to create or change a set of parameters, you should select an Expert Advisor at the "Settings" tab of the strategy tester and specify necessary input parameters and ranges of their variation at the corresponding tab.


 
Rosh:

Have seen section "MetaTrader 5 Help → Getting Started → Terminal Start → Additional Parameters"?


Yes...this is where the "ExpertParameters" section has been removed...from the MT4 documentation:

From the MT4 User Guide

I got my new release yesterday...Sleep() is working...IsFileExists() was my programming error.

Thanks...ChuckM

 

I am having problems with duplicating the results of the Optimization Results.  If I change my inputs to what the Optimization Results has, I get something completely different.  For example: optimize tester shows a profit and running the EA with the same settings in a single test run gives me a loss.

Should I be able to duplicate the Optimization Results in the expert testing in a single setting single pass test?  I would think that I should be able to, or what is the point of testing in the optimization mode. 

I do not have any code like what is listed above.  I am a new programmer as well, so I have some questions about the above code.  Do I need the above code somewhere in my EA to run Optimization - Fast genetic based algorithm and be able to duplicate the results?  If not, then could get I some info about what the above code is for in an EA?

 

Yes, you are right. Result of single pass must be the same as in optimization pass.

Please make sure that:

  • you set the same period, tick generation mode, etc.
  • you are connected to the same server using the same access point

If you are getting a different results of single pass and optimization pass you better write to servicedesk. Please do not forget to attach logs of tester and agents, source code of your EA and description of results.

 
Automatic optimization?  Sounds interesting
Reason: