Walk-forward testing: how to tell whether a trading strategy holds up
By the PipYard team · 7 min read · Updated
A backtest answers one question: how would these rules have done on this history? If you chose the rules' settings by looking at that same history, the answer is mostly about how well you fitted the past. Walk-forward testing separates the data used to choose settings from the data used to judge them, and repeats that across the whole history.
Why a single backtest flatters a strategy
Every strategy has settings: a lookback, a stop distance, a session filter. Try enough combinations on eight years of gold and one of them will look excellent, because some combination always fits the noise in that particular stretch of prices. This is overfitting, also called curve fitting. The more settings you try, the better the best one looks, and the less that result tells you about next month.
The cure is not to stop optimising. It is to judge the optimised strategy only on prices it never saw while its settings were chosen.
How walk-forward testing works
- Train. Take a window of history, for example 24 months, and choose the settings that do best on it.
- Test. Run those exact settings on the next window, for example the following 3 months. Nothing about this window influenced the choice.
- Roll forward. Move both windows on by the length of the test window and repeat until you reach the end of your data.
- Join the test windows. Put every test window's trades together. That joined result is the out-of-sample result, and it is the only one that counts.
On eight years of history with 24-month training and 3-month test windows, you get roughly 24 test windows. Each one is a small, honest experiment; together they show whether the method of choosing settings keeps working as markets change.
Choosing the windows
- Training long enough to be stable. Too short and the chosen settings jump around from window to window. Two years is a sensible start for H1 and H4 strategies.
- Test windows short enough to adapt, long enough to trade. A test window with two trades tells you little. Three months suits most intraday and swing strategies.
- Enough trades overall. Fewer than about 100 out-of-sample trades leaves too much room for luck. PipYard's release gate asks for at least 100.
- Decide before you look. Choose the windows and the pass criteria first. Changing them after seeing results is another way of fitting the past.
PipYard uses 24-month training and 3-month test windows unless you choose others.
Which numbers to read
Read the out-of-sample numbers only, and read several together (each is explained in which backtest numbers matter):
- Average result per trade, in R. R is the amount risked on a trade (entry to stop). An average of +0.10 R means each trade made a tenth of its risk on average, after costs. It doesn't depend on lot size, so strategies can be compared fairly.
- Profit factor. Gross profit divided by gross loss. Below 1 loses money; small margins above 1 often disappear with real costs.
- Maximum drawdown. The deepest fall from a peak. Ask whether you would have kept running the strategy through it.
- Share of profitable test windows. A result carried by one lucky quarter looks different from one that earned in most quarters.
- Trade count. Every number above is less reliable when it rests on few trades.
Why not win rate? A strategy can win 80% of trades and lose money if the losses are large. Hit rates can also mislead in a quieter way. In our earlier research on gold, M15 data from 2018 to 2026, price reached the 161.8%, 261.8% and 423.6% Fibonacci extensions of a failed-retrace setup about 80%, 54% and 38% of the time. Those sound impressive until you run the same measurement on random prices: about 76%, 51% and 32% (the full report). A hit rate close to what chance gives is not evidence. That is why PipYard ranks results by average R per trade.
Gold figures from FXEngine research that preceded PipYard, not yet reproduced in PipYard; random-price figures rerun on 25 Nov 2026. Simulated results. Past performance does not guarantee future results.
Costs belong in the test
A strategy that trades often lives or dies on spreads, commission and slippage. Test with the costs your broker actually charges, and treat high-impact news windows with care: spreads widen and fills slip exactly when many strategies trigger. PipYard's reports state the spread, slippage and news-window settings each test ran with, so two results can be compared on the same terms.
Set the pass line before you test
A written pass line turns a test into a decision. PipYard applies the same release gate to every strategy before it can run on a demo account:
| Check | Needs |
|---|---|
| Out-of-sample trades | at least 100 |
| Profit factor | at least 1.25 |
| Sharpe ratio | at least 0.8 |
| Max drawdown | at most 15% |
| Profitable test windows | at least 60% |
| Average result per trade | above 0 R |
A strategy that misses any line can still be studied and changed; it just can't move to the next step until a new version passes.
What walk-forward testing can't tell you
- It can't promise the future. Markets change in ways no history contains.
- It can't fix bad data. Gaps, wrong time zones or a broker's different daily close change results.
- It can't undo a search over thousands of variants. If you test many strategies and keep the best, its out-of-sample result is still flattered by the search. Keep a count of what you tried.
- It doesn't test execution. Fills, delays and missed signals only show up when the strategy runs live on a demo account: see backtest vs forward test.
Running one in PipYard
Describe the rules in the visual builder, in code, or in conversation with Claude or ChatGPT (how that works). Choose the price history: your own broker's MT5 history through the PipYard Connector, or an uploaded file. PipYard runs the walk-forward on its servers, shows every fold and trade, and checks the release gate. An eight-year walk-forward on H1 usually takes about one compute credit; the Free plan includes 60 a month.