Walk-forward optimization tests a trading strategy the way you would have traded it. You choose its settings on one stretch of history (in-sample), test those settings on the stretch that follows (out-of-sample), then move both windows forward and repeat. The out-of-sample pieces, joined together, are the honest estimate of how the strategy would have done.
You end with a run of out-of-sample results, each produced by settings chosen only on the data before it. Joined in date order, they show how the strategy would have done if you had re-tuned it as you went. Read the settings each window chose as well: if the best lookback jumps around from one window to the next, the choice is fitting noise. A strategy whose good settings sit on a wide, flat plateau is more likely to hold up.
The three names describe one loop. Walk-forward optimization puts the weight on the tuning step: choosing settings on each in-sample window. Walk-forward analysis puts it on reading the result: how much performance survives out of sample, and how stable the chosen settings are. Walk-forward testing puts it on the out-of-sample runs themselves, and is the name most backtesting tools use for the feature. Keel’s page on walk-forward testing says what Keel supports today.
When in doubt, run both. A strategy that passes one and fails the other is telling you how much it depends on recent conditions.
Walk-forward efficiency (WFE) is the out-of-sample Sharpe divided by the in-sample Sharpe for a window. Some loss is expected, because the in-sample number is the one the tuning flattered. The walk-forward analysis tool uses a simple heuristic: a window passes when its out-of-sample Sharpe keeps more than half of a positive in-sample Sharpe, and you read the share of windows that pass. That is a rule of thumb, not a statistical test. To test how likely a chosen setting is to be overfit, see the probability of backtest overfitting and the deflated Sharpe ratio.
The walk-forward analysis tool loads a sample daily returns series whose regime changes halfway through. Run it anchored, window 96, step 96, and you get these folds. The in-sample window grows from the first bar; the out-of-sample window is the next 96 bars.
| Fold | IS bars | OOS bars | IS Sharpe | OOS Sharpe | WFE | Pass |
|---|---|---|---|---|---|---|
| W1 | 1–96 | 97–192 | 4.20 | 1.40 | 0.33 | no |
| W2 | 1–192 | 193–288 | 2.84 | 3.38 | 1.19 | yes |
| W3 | 1–288 | 289–384 | 3.03 | 1.48 | 0.49 | no |
| W4 | 1–384 | 385–480 | 2.42 | 1.74 | 0.72 | yes |
Mean out-of-sample Sharpe 2.00, mean degradation −31.9%, 2 / 4 folds passing. W1 was tuned on the strong regime and kept a WFE of only 0.33 once the regime turned. The failing folds are W1 (WFE 0.33) and W3 (WFE 0.49). With that pass rate you would not trade this series on the strength of its in-sample Sharpe. The numbers are the tool’s own output for these settings, and a test keeps them equal.
A single split tests your settings once, against one out-of-sample period. If that period happens to suit the strategy, the result looks better than it should; if it does not, a good strategy looks broken. Walk-forward tests against many periods, so you see the spread of out-of-sample results rather than one draw. The cost is more runs, and a shorter out-of-sample window each time. An untouched holdout at the very end is still worth keeping on top of the loop; the out-of-sample testing guide covers how to split the data.
Keel’s Research re-picks a strategy’s settings as it goes, using only the days before each pick, as in Keel’s study below. To drive a windowed loop of your own, with the windows and the choices yours, Keel runs a backtest over any date window:
keel backtest run <strategy> --start-date … --end-date …. Keep the out-of-sample runs and note the settings each window chose.return_pct column in date order into one series, one return per closed trade.| every (Days between re-picks) | lookback days (Days looked back) | Sharpe |
|---|---|---|
| 7 | 60 | 0.85 |
| 14 | 60 | 0.60 |
| 30 | 60 | 0.69 |
| 60 | 60 | 0.75 |
| 7 | 90 | 0.96 |
| 14 | 90 | 1.01 |
| 30 | 90 | 0.72 |
| 60 | 90 | 0.86 |
| 7 | 180 | 0.88 |
| 14 | 180 | 0.85 |
| 30 | 180 | 0.86 |
| 60 | 180 | 0.50 |
| 7 | 365 | 0.054 |
| 14 | 365 | 0.17 |
| 30 | 365 | −0.13 |
| 60 | 365 | 0.016 |
Keel's study of Momentum Strategy on Hyperliquid · computed Nov 16, 2026 · data Aug 15, 2024 to Sep 29, 2026
Keel is a strategy builder for Hyperliquid. Describe an idea, backtest it with fees, slippage and funding, and run it live on Hyperliquid’s crypto perps. Stock and index perps are coming soon.
Start free. Connect a Hyperliquid wallet when you’re ready to trade.
A way to test a strategy's settings on data they were not chosen on, many times over. You pick the settings on one window of history (in-sample), test them unchanged on the window that follows (out-of-sample), then move both windows forward and repeat. The out-of-sample results, joined in date order, estimate how the strategy would have done if you had re-tuned it as you went.
The same loop, with the weight on reading the results: how much of the in-sample performance survives each out-of-sample window, and whether the chosen settings stay stable from one window to the next. Walk-forward analysis, walk-forward optimization and walk-forward testing name one procedure.
It is a time-ordered kind of cross-validation. Standard k-fold shuffles the data into folds, so a model can learn from bars that come after the ones it is tested on. Walk-forward only tests on data that comes after the data the settings were chosen on, so no future information leaks in. It is close to blocked, time-aware k-fold run in date order.
Long enough that each in-sample window holds enough trades to tell a good setting from a lucky one, and each out-of-sample window holds enough trades to judge it. A common starting point makes the in-sample window a few times longer than the out-of-sample one. A strategy that trades a few times a month needs far more history per window than one that trades every day.
Walk-forward efficiency is a window's out-of-sample result divided by its in-sample result. Some loss is normal, because tuning flatters the in-sample number. The walk-forward analysis tool counts a window as passing when it keeps more than half of a positive in-sample Sharpe; that line is a rule of thumb, not a statistical test. A heavily tuned strategy that keeps nearly all of its in-sample Sharpe on every window is a reason to look for a leak.
Keel's Research runs a version of it. Its Check a strategy step "Re-picking the settings as you go" re-picks a strategy's setting from a grid every few days, using only the days before each pick, and follows what it picked, so you see how re-picked settings did on the days after (on the plans that include it). It measures; it never changes your strategy's settings. For a windowed loop of your own, run a backtest over any date window, in the app or with keel backtest run <strategy> --start-date … --end-date …, and paste the joined out-of-sample returns into the walk-forward analysis tool.
In-sample vs out-of-sample, holdout and walk-forward splits, and the crypto pitfalls.
Paste a returns series and see in-sample vs out-of-sample Sharpe per window.
The full backtesting guide: data, costs, common mistakes and how to check a result.