Optimization of the trading algorithm: Walk forward optimization
Hey there, Protraders!
In the previous article we considered in detail the optimizer setup in the Protrader platform. In the current article we will introduce the verification method of the trading system optimization parameters on the sustainability.
Why is it so important? Practice shows, the usage of different optimization algorithms does not guarantee the sustainability of the received «optimal» trading system settings. Sustainability refers to the ability of the system practically not to change their statistical data while testing on historical data which were not a part of the optimization selection. Data selection on which the system optimization was held is called the «In Sample» section. And the data that was not included in the optimization selection is called the «Out of Sample» section. Often «Out of Sample» data goes after «In Sample» section by the timeline. Thus, «Out of Sample» section is located in the future relatively to the section «In Sample». Therefore, such type of the trading systems testing was named «Forward test». The purpose of this testing type is to determine the sustainability of the trading system settings obtained during optimization. Using the «Forward test» you can exclude those system settings that are simply «fit» under the history plot on which the optimization was held. On the «Out of Sample» section, such «fit» settings rapidly losing its effectiveness or even stop working. The systems with a large number of the optimized parameters or degrees of freedom are most susceptible to «fitting». This indicates that the system does not trade the certain trading situation, which was laid in its logic, but simply «adjusts» under the historical data. And since the behavior of financial instruments has a high degree of volatility to profit from the use of «fitted» systems is practically impossible.
Ready-to-use tool to solve the problems of sustainability of the trading system optimized settings that were described above is implemented in the Protrader terminal. This tool is called as «Walk forward» optimization. Using this tool a trader can with one operation hold the optimization of the trading system parameters and also its «Forward test».
To start the «Walk forward» optimization, go to AlgoStudio - > Optimization and select «Walk forward» in the drop-down list.
After selecting the «Walk forward» optimization as well as the optimization algorithm and its parameters, you can move on to configuring the «Walk forward».
Two parameters are available for the trader in the «Walk forward» setup window. «IS period» is a section of historical data on which the optimization will be held («In Sample»).
«OS period» is a section of historical data on which the «Forward test» will be held («Out of Sample»).
Thus, the total optimization period which is set in «Backtesting setup» settings is logically divided into «IS period» and «OS period» sections. The optimization of the trading system parameters is held on the «IS period» section and the sustainability verification of the optimized parameter set of the trading system is held on the «OS period» section. In the current example the «Walk forward» optimization is held on the trading instrument EURUSD, from 01.01.2013 to 01.01.2014, herewith the total optimization period is divided into sections «IS period» = 30 days and «OS period» = 30 days.
After holding the optimization, we obtain the results table that is similar to the results table of ordinary optimization. But it will include several new indicators.
Let’s decipher the meaning of the new indicators in optimization result table:
«Type» – is the type of operation which is held. The «Optimization» value means that the optimization was held at this time interval. The «Backtesting» value means that the testing was held at this time interval.
«Start time» and «End time» – are respectively the beginning and the end of the selected period.
«Robust» – is the sustainability indicator of the selected trading system settings which is measured in percent. This value is calculated as the ratio of optimization target function value on the «Backtesting» section to the optimization target function value on the «Optimization» section, expressed in percent. Example: during the optimization period the best set of the trading system settings shows the target function value = 10; the same system settings show the target function value = 5 on the testing section. Robust = (5/10)*100% = 50%.
Thus, with the help of the «Robust» indicator we can determine how stable the optimization results are, and avoid the use of the «fitted» trading system settings. As we can see in the current example, all testing sections showed negative values of the «Robust» indicator, indicating the extreme instability of the obtained optimal sets of the trading system settings. The «Walk forward» optimization module can be used not only for easy sustainability verification of the optimized trading system settings, but also for selection of the trading system optimal parameters using «sliding window». After all, there is a class of trading systems that requires constant monitoring of the optimal parameters which are very sensitive to the dynamics change of the traded financial instruments. The length selection of the «IS period» and «OS period» sections depends on the specifics of the optimized trading system as well as on the dynamics of the used financial instrument. As an example, during the low volatility periods and consolidation the trend system will show results worse than during the high volatility periods and trend market.
In this article we reviewed «Walk forward» optimization module which is implemented in the Protrader terminal. This module will not only help the trader to check quickly and easily the sustainability of the trading system optimal parameters but also will give a possibility to hold the optimization easily using the «sliding window», that is necessary when using some types of trading systems.