Discussion of article "Custom Walk Forward optimization in MetaTrader 5"

 

New article Custom Walk Forward optimization in MetaTrader 5 has been published:

The article deals with the approaches enabling accurate simulation of walk forward optimization using the built-in tester and auxiliary libraries implemented in MQL.

After completing the optimization, we will have multiple sets of parameters for each window W with the shift of i steps. The best set will be defined among them. The pass index number allows us to get trading results at the next test segment S immediately. By combining them together, we will obtain a full report on forward testing for several cycles within D.

Forming the walk forward test

Fig. 1. Forming the walk forward test

Author: Stanislav Korotky

 
Is it correct that walk-forward is an auto-optimisation? Accordingly, cluster analysis is auto-optimisation?
 
fxsaber:
Is it correct that walk-forward is an auto-optimisation? Accordingly, cluster analysis is an auto-optimiser optimisation?

Not exactly. Auto-optimisation is an algorithm built into the EA that adjusts EA parameters on the fly (I have it in my blog in English, in several parts - the beginning). Walk-forward is an emulation of this process on history, not online, and the tester does the optimisation, but the EA can't optimise itself - if it could, there would be no need for WFO - you just run the EA in the carrot tester and get a full report on the forward. Besides, the results of cluster analysis are not automatically applied to the next step of walk-forward or simple optimisation. This is probably implemented in some programmes.

MQL's OOP notes: On The Fly Self-Optimization of Expert Advisers: part 1
MQL's OOP notes: On The Fly Self-Optimization of Expert Advisers: part 1
  • www.mql5.com
Are you ready for a very very long story? It will be probably most complicated and prolonged publication in the series of MQL OOP so far, but it's surely worth reading, because its main theme is automatic self-optimization of expert advisers on the fly. This is one of the most frequently asked questions of MetaTrader users. And the answer so...
 

If auto-optimisation in the Tester, it can also be implemented online. In general, thank you, I understand.

This case can be implemented for Expert Advisors without sources.

 
fxsaber:

If auto-optimisation in the Tester, it can also be implemented online. Anyway, thanks, got it.

This case can be implemented for Expert Advisors without sources.

MQL5 still does not have an API for tester management, so online auto-optimisation through the tester is possible only in a "crutch" version.

 
Stanislav Korotky:

MQL5 still does not have an API for tester management, so online auto-optimisation through a tester is possible only in a "crutch" version.

At the moment, I do not see any limitations.

 

Hello. Could you please tell me if it is possible to realise a similar approach by MT5 using the following algorithm:

1. Optimisation on a segment (e.g. a month) then test on the next segment (e.g. also a month) on parameters of the best profit / highest number of trades or other user defined parameters.

2. Shift for a certain period (let it be a month again) with recording the results in a file. For example - let's explore 2018.

1 month - optimisation, 2 month test on settings with best profit - record results

2 month - optimisation 3 month test on the settings with the best profit - record results

......

11 month - optimisation 12 month test on settings with better profit - record results?

 
Luchezar Shalomaev:

Hello. Could you please tell me if it is possible to implement such an approach by MT5 means according to the following algorithm:

1. Optimisation on a segment (e.g. a month) then test on the next segment (e.g. also a month) on the parameters of best profit/largest number of trades or other user defined parameters.

2. Shift for a certain period (let it be a month again) with recording the results in a file. For example - let's study the year 2018.

1 month - optimisation, 2 month test on the settings with the best profit - record the results

2 month - optimisation 3 month test on the settings with the best profit - record results

......

11 month - optimisation 12 month test on the settings with the best profit - record results?

This is what the article is about. Currently implemented without having to edit the original EA.

It is done through the means of automatic control of the Tester. I have not yet had the time to post the finished solution.

 
fxsaber:

This is what the article is about. Currently implemented without having to edit the original EA.

It is done through the means of automatic control of the Tester. I have not yet had the time to post the finished solution.

Thanks, will this work if I put my EA in it?

#include <WalkForwardOptimizer.mqh>

...

int OnInit(void)
{
  // your working code is here
  ...

  // optional, default wfo_built_in_loose
  wfo_setEstimationMethod(wfo_estimation, wfo_formula);

  // optional, default DBL_MAX
  wfo_setPFmax(100);

  // optional, default false
  // wfo_setCloseTradesOnSeparationLine(true);
  
  // mandatory, all parameters from the header file
  int r = wfo_OnInit(wfo_windowSize, wfo_stepSize, wfo_stepOffset, wfo_customWindowSizeDays, wfo_customStepSizePercent);...............
 
Luchezar Shalomaev:

Thanks, will this work if I put my EA in there?

That's for the author of the article. But it is still designed for programmers.

 
Luchezar Shalomaev:

Thanks, will this work if I put my EA in there?

The given code is incomplete - you need to use some more handlers - it is in the examples. But you need the library itself (not just the header file). If you have purchased the library, please write in private.