• Overview
  • Reviews (1)
  • Comments


This script allows performing a walk-forward analysis of trading experts based on the data collected by the WalkForwardLight library. The script builds a cluster walk forward report and rolling walk forward reports that refine it, in the form of a single HTML page. Since the library generates files with the metadata in the "tester\Files" directory (during the optimization), it is necessary to manually move the files to the "MQL4\Files" directory.

The script only works in conjunction with the library. The library is purchased separately and must be included in an expert.

There is a similar script for MetaTrader 5 - WalkForwardBuilder MT5, although it is auxiliary, as the MetaTrader 5 version of the library - WalkForwardLight MT5 - automatically creates files with the metadata in the "MQL5\Files" directory and builds reports.

A detailed User's Guide (in Russian) is available in the blog.

This script performs a walk-forward analysis using an unconventional method (details are in the User's Guide). There is another set of tools - the WalkForwardOptimizer library and the WalkForwardReporter script (their MetaTrader 5 counterpart is the WalkForwardOptimizer MT5 library, which does not require the script) for those, who want to adhere to the standard procedure more accurately (as much as possible with an implementation in the built-in tester without third-party programs).

Input parameters

  • CSVFolder - name of the folder with the metadata files; is left blank, the script looks for the folder name in the WFL_FILE_ global variable created by the library;
  • Estimator - optimization criterion; available values - wfo_profit, wfo_sharpe, wfo_pf, wfo_drawdown, wfo_profit_by_drawdown, wfo_profit_trades_by_drawdown, wfo_average;

Metrics in reports

Cluster report

The cluster report at the top of the HTML page contains generalized tables of expert's forward testing results at different ombinations of the optimization window sizes and the forward testing step sizes. The columns correspond to the window sizes of 10%, 20%, 30%, 40%, 50% of the total date range in the tester settings. The rows correspond to the forward step sizes of 5%, 10%, 15%, 20%, 25%, 30% from the window size. All percentages are recalculated to bars (see the Bars table).

The cluster report consists of the following tables:

  • annualized profit/loss - the hypothetical profit of the EA per year, with the earnings recalculated in proportion to the optimization and testing periods.
  • efficiency - the ratio of the annual profit on testing period and optimization period of the same pass.
  • consistency - percentage of profitable passes among all test passes of the "spliced" forward test.
  • bars - the size of the window and step in bars.

All tables cells in the cluster report are links, clicking them allows to quickly navigate to the corresponding refinement report.

Refinement reports

The refinement report contains details of how the forward testing metrics were obtained for a particular combination of the size of the optimization window and the forward step. The rows in the refinement report correspond to the tester runs, where the best parameters for the optimization window were found. The results of the subsequent test on a forward step, calculated in the same tester run, are displayed in the same row.

The columns contain the start and end dates of the optimization window, the forward end date, as well as the following metrics for two periods at the same time - optimization window (blue background) and forward test (yellow background): profit, profit factor (Sharpe ratio can be selected), profit, loss, the number of successful and unsuccessful trades, as well as the drawdown in physical terms and in percentage terms. The right column with the pass number allows determining the correspondence between this report and the standard optimization report of the tester, in particular for obtaining input parameters and running a single test.

It also displays the average, maximum, minimum values and variance; annual profit, efficiency, stability and drawdown of the "spliced" forward test on all steps, as well as a schematic representation of the balance curve of the forward test.

Ali irwan
Ali irwan 2017.07.29 00:53