Discussion of article "Continuous Walk-Forward Optimization (Part 4): Optimization Manager (Auto Optimizer)"

 

New article Continuous Walk-Forward Optimization (Part 4): Optimization Manager (Auto Optimizer) has been published:

The main purpose of the article is to describe the mechanism of working with our application and its capabilities. Thus the article can be treated as an instruction on how to use the application. It covers all possible pitfalls and specifics of the application usage.

To proceed with the analysis of the created program we first need to define the purpose of this project. We decided to use a scientific approach in trading and started creating clearly programmed trading algorithms (no matter whether we deal with indicator-based robots or those applying fuzzy logic and neural networks — all of them are programmed algorithms that perform specific tasks). Therefore, the approach to the selection of optimization results should also be formalized. In other words, if during refuse to apply randomness in the trading process, then the process of preparation for trading should also be automated. Otherwise, we can select the results that we like randomly, which is closer to intuition than to the system trading. This idea is the first motive that encouraged me to create this application. The next one is the possibility to test algorithms by optimizing them — by using the Continuous Walk-Forward Optimization shown in the below figure.   


Continuous walk-forward optimization alternates between historical (yellow) and forward (green) optimization passes at a given time interval. Suppose you have a 10-year history. We determine that the optimization period should consist of an interval equal to 1 year, and a forward interval of 1 quarter (or 3 months). As a result, we have an interval equal to 1.25 years (1 year + 1 quarter) for one optimization pass + a forward test. In the figure, each line characterizes this time interval.

Author: Andrey Azatskiy

 
Serious work. It would be interesting to compare results between different implementations of auto-optimisation on the same EA.
 
fxsaber:
Serious work. It would be interesting to compare results between different implementations of auto optimisation on the same EA.

Thank you for the positive feedback

 

It's a real feat on your part to do such work on a voluntary basis. There is a week's worth of writing and about half a year of code development. Isn't automation of optimisation the most important task for the client part of the terminal? Unfortunately MQ do not pay attention to it and pay more attention to brokers' requests (they pay). It is strange that there is no explosion of enthusiastic comments from users. What, no one is optimising?

I haven't had a chance to compile the project yet, only to see the interface in debug mode and read the article, but it all looks extremely promising. I need to find instructions on how to compile in Visual Studio.

It would be nice to add the ability to enumerate tools in the market overview for each optimisation interval. It will require power, but on short intervals it will be possible to evaluate the result. Well, maybe Russian localisation? But everything is clear as it is.

I shake your hand and bow for your labour.

 
Good Beer:

It's a real feat on your part to do such work on a voluntary basis. There is a week's worth of writing and about half a year of code development. Isn't automation of optimisation the most important task for the client part of the terminal? Unfortunately MQ do not pay attention to it and pay more attention to brokers' requests (they pay). It is strange that there is no explosion of enthusiastic comments from users. What, nobody optimises it?

I haven't had a chance to compile the project yet, only to see the interface in debug mode and read the article, but it all looks extremely promising. I need to find instructions on how to compile in Visual Studio.

It would be nice to add the ability to enumerate tools in the market overview for each optimisation interval. It will require power, but on short intervals it will be possible to evaluate the result. Well, maybe Russian localisation? But everything is clear as it is.

I shake your hand and bow for your labour.

Thank you for your comment, I hope my developments will be useful. In future articles, we will describe how to build the project in VS and how you can implement your own optimisation logic.

Regarding compilation, if you run the project in debugging mode in the studio, it has already been compiled. You can find it in the MetaTrader Auto Optimiser/bin/Debug directory

 

I haven't started your programme yet, but the first questions have already appeared:

1. Did I understand correctly - no user-defined optimisation criterion is supported? It would be very much needed.

2. How is continuous optimisation sliding ensured? Do you have to enter all optimisation and forward ranges manually? Why not implement it like this:

Optimisation start date/optimisation period (month; week; day)/optimisation perid scale/forward period/forward scale. Programmatically divide the period into passes. I did this in the multitester. But a year of writing out even a week at a time will blow your mind. And scalping can also be used.

3. Just a curiosity: Why do you need the macro substitution "TESTER_ONLY"? The Expert Advisor will unload from the chart without it.

 
Good Beer:

I haven't started your programme yet, but I already have the first questions:

1. Did I understand correctly - no user-defined optimisation criterion is supported? It would be very much needed.

2. How is continuous sliding of optimisation provided? Do you have to enter all optimisation and forward ranges manually? Why not implement it this way:

optimisation start date/optimisation period (month; week; day)/optimisation perid scale/forward period/forward scale. Programmatically divide the period into passes. I did this in the multitester. But a year of writing out even a week at a time will blow your mind. And scalping can also be used.

3. Just a curiosity: Why do you need the macro substitution "TESTER_ONLY"? The Expert Advisor will unload from the chart without it.

1. I did not fill in the custom criterion, as many different other substituted, but in the future, if I think to develop the project (as all the articles in this series will be completed, 2 more I plan) - you can add it, it is not difficult. Even a reasonable decision, thank you for your advice.

2. Regarding the dates, you only need to enter them once, then save them to a file and then just load the saved file in the future. I made this breakdown from the fact that I use it myself for stock market tests on the futures market. Futures are tested on staples, and the staple dates are not fixed and are provided by the broker. As a result, I manually set the breakdown of staples so that the test period does not fall on the moment of stapling. You just need to enter the required optimisation windows once, save them to a file and then just load this file.

3. a macro that would not run accidentally on real life. The Expert Advisor is test much is not finished for real trading. I decided to put #define this one so that someone would not accidentally run it in real trading. Thanks to this #define, the Expert Advisor is allowed to work only in the tester, and if you load the robot on the chart at once, it will simply be deleted.

 
Good Beer:

2. How is continuous sliding optimisation ensured? ...

In the final article - I will describe step by step the whole process of providing sliding optimisation with the code attached. The point is that the optimisation algorithm itself is implemented separately. And as I mentioned earlier, you can add another algorithm to the current optimisation algorithm.

 

Good Beer:

I haven't managed to compile the project yet ...

The easiest and fastest way to compile is to open the project and press CTRL+SHIFT+B.

More visual - click on the green arrow in the editor, the application will be launched in the code debugging mode, but compilation will take place too.

Another option - from the drop-down menu, click Build

Later on the pathMetaTrader Auto Optimiser/bin/Debug (or MetaTrader Auto Optimiser/bin/Release, depending on the selected build type) - the compiled program will appear.

 

Several optimisation criteria can be entered in the sorting window. How are they to be multiplied? You can't do without a custom one anyway. For example, it is good to take the number of transactions as the root of it or take the Sharpe modulo the number of transactions. Please don't give up this idea.

The list of periods can be created using MQL tools.

About #define TESTER_ONLY I meant that the expression in brackets will work without TESTER_ONLY. I don't understand why you need to use substitution? I've seen it many times.

 
Good Beer:

Several optimisation criteria can be entered in the sorting window. How are they to be multiplied? You can't do without a custom one anyway. For example, it is good to take the number of transactions as the root of it or take the Sharpe modulo the number of transactions. Please do not give up this idea.

The list of periods can be created using MQL tools.

About #define TESTER_ONLY I meant that the expression in brackets will work without TESTER_ONLY. I don't understand why you need to use substitution? I've seen it many times.

Well, as soon as I finish the first version of the article, I'll plan a continuation, still there are some ideas I would like to implement.

List of periods - exactly in the auto optimiser is needed, it switches tests itself and should see these periods (according to the logic of the resulting program).

Regarding the define:

#ifdef  TESTER_ONLY
   if(MQLInfoInteger(MQL_TESTER)==0 &&
      MQLInfoInteger(MQL_OPTIMIZATION)==0)
     {
      Print("This expert was created for demonstration! It is not anabled for real trading !");
      ExpertRemove();
      return(INIT_FAILED);
     }
#endif

The expression is wrapped in the #ifdef #endif construct - it is a condition executed at compile time. If you compile the project by defining #define TESTER_ONLY, the expression wrapped in this condition will be included in the build, if you do not declare it, it will not be included. I made it so that if someone wants to experiment and run the robot at his own risk on the real, all that is needed is to comment out #define TESTER_ONLY - without changing the source code.



The method of taking into account several selected sorts is described in the first article of this series. Everything happens there through parameter normalisation. However, as I said before, you can create your own optimiser and make your own system of accounting for these parameters - it will be described in a forthcoming article.