Tuesday, October 17, 2017

Doing Walk-Forward in MQL5 using regular tester. Part 1.

Doing Walk-Forward in MQL5 using regular tester. Part 1.

What is a Walk-Forward Testing?

In simple terms, Walk-Forward Testing emulates periodically reoptimization Adviser and his trade on historical data.

That is, for example: optimization conducted for 3 months (In Sample / Back Test), choose the best set of parameters, with this trade a set 1 month (Out Of Sample / Forward Test). Then again to optimize for 3 months, choose the best and trade with a set of these a month. And so on.

Test Result (except the first portion IS), as we have seen, consists of following each other OOS green portions, i.e. fair trade areas.

What gives Walk-Forward Testing?

This test allows to historical period evaluate the stability of the system on Forward-sites and identify those parameters of a system that makes sense to optimize.

If the test result on forward areas of the system shows poor results, the reasons 3:

1) The trading system is hopeless, or you need to change or modify its algorithms
2) chose the wrong settings to optimize
3) After optimization selected set inopportune

Choosing the right parameters and sets - a separate issue, because some of the parameters cause reoptimization, and 15-20 sets only a few are quite working.

Hand Walk Forward using regular tester

The first thing that comes to mind - to run full-time tester MT5 in all areas with the included forward. Choosing the best set found in the area of ​​optimization and record the results of his striker. After running the last section, the results of forwards summarize. This will be the result of trade.

Very time-consuming activity, especially when there is a need to develop a system and assess the impact of each innovation.

Variations on a theme can be a collection of statistical data at each site (which is possible to do in a shopping robot through the optimization of frames) with subsequent analysis of forwards in third-party programs.

Automatic Walk Forward using regular tester

Affordable option in a regular tester could be:

Walk-Forward Testing would be like a normal single run in which the balance of the graph built from Forward stations.

But what is not, that is not.


Can I now using MT5 tester to optimize and forward runs sequentially on separate pieces of the history and get the final result of a button click?


As it turns out, you can, when working on such a scheme:

  1. Running in the tester immediately the whole period in the optimization mode Brute force.
  2. Moved only one service parameter. We will need a large number of iterations, so the number of steps needed to set with a margin for example, 100 000 (this can be done programmatically through ParameterSetRange).

On the part of the tester all. The rest of the program implements written in MQL5.


What happens in the software part:

  1. Conducted counter areas. On the basis of this counter are allowed to trade advisor N days (In Sample plot).
  2. Enumerating values ​​expert parameter and result analysis software is being built through genetic algorithm. (Tester at each iteration just dutifully spit out the results of trade with the modified parameters in the frames)
  3. According to the results of genetic optimization sets (with custom criteria, for example based on the minimum loss, maximum profit and maximum number of transactions) is set winner.
  4. In the next iteration Adviser allowed to sell M days (OOS on the first section), the result of trade we remember.
  5. Making portions increment the counter, and go to step 1.

As soon as portions of an end, we translate an expert in stop mode, and full-time optimizer quickly ends is not required too much service parameter.

The whole process can be visualized as when operating in the analysis mode terminal frame starts with a flag expert MQLInfoInteger (MQL_FRAME_MODE)

All the above tested in draft form, without genetic search algorithm as I do not have it MQL implementation.

In the second part of the article will show visualize the results of runs with search parameters without genetics.



No comments:

Post a Comment