VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Backtesting and validation

Walk-forward optimization setup: windows, splits, parameters

The settings that decide a walk-forward optimization: how much of each run stays out of sample (a common split is 20%, which is also AlphaPrime's default), how the windows roll, what efficiency tells you, and which setup mistakes let the test cheat.

By · Published · updated · Editorial policy

Contents
  1. How do you split in-sample and out-of-sample data?
  2. How does the rolling window move forward?
  3. What does walk-forward efficiency tell you?
  4. What can walk forward optimization catch, and what can't it?
  5. Which setup mistakes break a walk-forward test?
  6. How is walk-forward set up in AlphaPrime?
  7. Frequently asked questions

Walk forward optimization comes down to a few settings, and this page goes through them. For why one backtest is not enough, read walk-forward analysis first. Here the job is practical: the optimizer tunes on one stretch of history, those settings trade untouched on the next stretch, and you judge only the stitched-together unseen parts.

That's the whole idea. Everything else is about setting the windows so the test can't cheat.

How do you split in-sample and out-of-sample data?

In-sample is the part the optimizer may look at. Out-of-sample is the part it may not. Parameters get picked on the in-sample block, frozen, and graded on the out-of-sample stretch right after it.

A common split puts 20% of each run out of sample. That's also the factory setting in AlphaPrime (Valynox). Smaller test legs mean more re-tunes, which is closer to how people run a system live.

Count trades, not years. Five years of a strategy that trades twice a month gives the optimizer about 120 trades to fit, and a 3-month test leg holds maybe six. Six trades is a coin toss.

How does the rolling window move forward?

The window slides forward by exactly one test leg, so the test legs line up end to end with no gaps and no overlap. Run two drops the oldest slice, folds in the slice run one just tested, and tests on the next.

Each run moves forward one test leg: every run tunes on an in-sample block and tests on the out-of-sample slice right after it, then slides forward by the length of that slice; only the out-of-sample slices are joined and judged Each run moves one leg Rolling windows, 20% out of sample IS OOS Only OOS legs are joined Judge that joined curve
Blue is in-sample (tuning), purple is out-of-sample (testing).

A rolling window keeps a fixed length and forgets old data. An anchored window keeps its start date pinned and grows.

I lean rolling for intraday futures. ES in 2015 and ES in 2022 were different animals, and an anchored window keeps letting a market that's gone vote on today's parameters. Anchored suits slow strategies that need every trade they can get.

What does walk-forward efficiency tell you?

Walk-forward efficiency (WFE) is how much of its in-sample profit rate a strategy keeps on unseen data, as a percentage. Near 100% is good. Near zero means the optimizer was mostly fitting noise.

My view, and plenty of people will disagree: WFE is the second number to look at, not the first. One test leg that catches a freak trend day can push it past 100% alone. I check the share of profitable runs first. And a run whose in-sample leg lost money has no real efficiency. A loss divided by a loss comes out positive and means nothing.

What can walk forward optimization catch, and what can't it?

It catches parameters that only worked in one period, which is most of what curve fitting looks like: a 14-tick stop that was perfect from 2017 to 2019 and useless after. Walk forward re-picks the stop every run and makes it prove itself on fresh data.

On 2026-10-15 we ran a held-out test on an RTX 3060 Ti with factory settings, conservative costs and 1 contract. On ES 60-min, 126 of the 250 strategies that passed the basic filters also passed walk-forward. On data held out from 2022-10, 91% of those that passed walk-forward were profitable, versus 53% of those that failed. On TAIEX futures 60-min it was 85% versus 66%. Both held-out periods were rising markets (ES about +116%, TAIEX futures about +29%), so the gap between the groups is what counts.

What it can't catch is a rule picked for the wrong reason. Say you saw ES bounce every time RSI touched 30 in 2020 and built a strategy on that. Walk forward will just re-tune the RSI level inside a rule you chose by looking at the answer.

Same with running walk forward 300 times and keeping the one that passed. You've just optimized the walk forward.

It isn't the last gate. AMonte Carlo backtest on the trade list and the checks in robustness testing for trading strategies come after it. For the gate that comes next, the free Monte Carlo simulator takes a trade list and shows how deep the drawdowns could go.

Which setup mistakes break a walk-forward test?

  • Windows too short. An in-sample block with 25 trades gives the optimizer only noise to learn. If a test leg can't hold 10 to 20 trades, lengthen it or use a slower timeframe.
  • Re-tuning on the out-of-sample. A test leg looks bad, so you widen a parameter range and rerun. That leg is now in-sample. I think this is the most common way people fool themselves with walk forward.
  • Mixing up units. 250 trading days is about a year; 250 calendar days is about eight months. We learned this the hard way building AlphaPrime's settings page: window lengths entered as percentages got read as bar counts, and the run that came back was a different study. Every length field now says its unit.
  • Leaving out costs. Results without commission and slippage flatter fast strategies most. See how to include trading costs.

How is walk-forward set up in AlphaPrime?

In AlphaPrime, walk-forward has its own Walk-forward tab. Factory settings:

SettingFactory value
Window movementRolling (anchored available)
Window unitPercent of the range (trading days or bars available)
OoS % of Run20%
Runs10
Optimization targetNet profit / max drawdown
Parameter search±30% around the original value, 10 steps
Tests per windowUp to 5,000, fixed seed so reruns match
Open position at window endClosed
Window boundariesSnapped to session edges

By default it re-tunes thresholds, entry parameters, indicator periods and stop loss / profit target. Trailing stops and exit-after-bars are opt-in, since each multiplies the grid.

The part I'd point you to is the walk-forward matrix (WFM). It runs a full walk forward for every combination of OoS % of Run (10% to 30%) and Runs (5 to 30), then looks for a 3×3 block of neighbouring cells where at least 7 pass. Passes at 20% and 10 runs but dies at 15% or 25%? You found a window length, not a strategy.

Every matrix cell is hundreds of backtests, which is where GPU backtesting stops being a nice-to-have.

First time? Keep the factory 20% and 10 runs, then run the matrix before trusting the result. If pass and fail flip one notch away, find out why before you trade it. What I still don't have a good answer for: a strategy that passes at every setting, but only because the whole test period went up.

Frequently asked questions

Is walk forward optimization the same as walk-forward analysis?

Most people use the two interchangeably. Strictly, optimization is the re-tuning inside each window, and walk-forward analysis is the whole test, judging included.

How many trades do I need in each out-of-sample window?

I want at least 10 to 20 per test leg, and a few times that in each in-sample block. Fewer than that and one lucky trade decides whether the window passes.

Rolling or anchored: which should I use?

Rolling for intraday strategies that trade often, since it drops old market behaviour. Anchored for slow strategies with few trades. Unsure? Run both and see whether the verdict changes.