What Is Walk-Forward Optimization?
Walk-forward optimization is a way to test a trading strategy on data its settings were never chosen on. The history is split into windows. In each window, the strategy's inputs are optimized on the first part (in-sample) and then traded, unchanged, on the part that follows (out-of-sample). The window then moves forward and the process repeats. The result is a chain of out-of-sample periods — the closest a backtest gets to how the strategy would have been traded in real time.
Why a normal optimization is not enough
A normal optimization runs every combination of inputs over the whole history and shows the best one. The problem: the "best" result was chosen because it looked best on that exact data. Some of its profit is real edge; some is just the noise of that period, fitted by the optimizer. A single backtest cannot tell the two apart.
Walk-forward optimization asks a harder question: if the inputs had been chosen with only the data available at the time, would the strategy still have made money afterwards?
How it works, step by step
One example layout:
- Split the history into segments. For example, 6 segments over 8 years.
- Inside each segment, split again: a longer in-sample part (say 80%) and a shorter out-of-sample part (20%).
- Optimize on the in-sample part only. Pick the winning inputs by a fixed rule, decided before looking at the out-of-sample data.
- Trade the winner on the out-of-sample part, with no changes.
- Move forward to the next segment and repeat.
- Join all out-of-sample results into one equity curve. That curve is the walk-forward result.
Two common layouts:
- Rolling: every in-sample window has the same length and slides forward.
- Anchored: every in-sample window starts at the beginning of the data and grows.
In the example above the segments don't overlap. Many rolling and anchored layouts do let in-sample windows overlap, and data that was out-of-sample earlier can become in-sample later. The one rule that never changes: each out-of-sample period is traded with inputs chosen only from data that came before it.
What a good walk-forward result looks like
- The joined out-of-sample curve is profitable, after commission and slippage.
- Most segments are profitable, not just one big winner.
- The out-of-sample results are not dramatically worse than the in-sample ones.
- The winning inputs don't jump wildly from one segment to the next.
What it cannot do
Walk-forward optimization does not make a strategy good. It shows, more honestly than a single backtest, whether the strategy was good on data it had not seen. Markets change, and past out-of-sample results still don't guarantee future ones.
Walk-forward testing in TradeStation with WalkStrat
WalkStrat is a TradingApp for TradeStation Desktop that runs this whole process on the user's own EasyLanguage strategy: it re-optimizes every in-sample window from scratch on TradeStation's own optimizer, picks each winner by fixed rules, and joins the out-of-sample periods into one walk-forward result, with an optional holdout period at the end that the optimizer never sees. All results are net of commission and slippage. More in the documentation.