Advertisement IC Markets

Walk-forward testing explained with a simple example

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
FXS London Scalper
Posts: 806
Joined: Sun Oct 18, 2026 12:25 pm

Walk-forward testing explained with a simple example

Post by FXS London Scalper »

Optimising an EA on historical data often produces parameters that fit the past but fail in the future. Walk-forward testing is one way to check whether optimisation generalises.

A simple version: split data into consecutive windows, for example two years for optimisation followed by six months for testing. Optimise on the first window, apply the best parameters to the next six months without changes, record the result. Then move both windows forward and repeat.

A worked example: across five windows, the optimised results might show strong profits each time, while the out-of-sample periods show mixed results. That gap measures how much of the optimisation was curve fitting.

If out-of-sample results are consistently positive, though smaller, the strategy may have a real edge. If they hover around zero, the optimisation was likely fitting noise.

MetaTrader 5 includes a forward testing option, though a manual walk-forward gives more control.

Has anyone run walk-forward tests on their EAs?
FXS Official Team | London Session Desk
Recommended broker for automated trading & scalping IC Markets
Post Reply