How to use the walk-forward efficiency calculator
- Run a walk-forward analysis in your backtesting software: optimize the parameters on an in-sample window, trade the best parameters on the out-of-sample window that follows, then roll both windows forward and repeat.
- Enter one row per window: a label, the annualized in-sample return of the chosen parameters, and their annualized out-of-sample return. The example has eight windows of a fictional strategy.
- Add the window lengths if you want the averages weighted by time, for example 24 months in sample and 6 months out of sample. Leave them empty to weight every window equally.
- Set the acceptable efficiency, 50% by default. Windows at or above it count as consistent.
The formula
Annualizing matters because the two windows rarely have the same length. Comparing 18 months of in-sample profit with 6 months of out-of-sample profit would make almost any strategy look degraded.
A worked example
The eight windows each optimize on 24 months and trade the next 6. In sample, the chosen parameters returned an average of 25.59% a year; out of sample, 10.26%. The walk-forward efficiency is 40%, below the 50% rule of thumb.
The detail tells a more nuanced story. The median window kept 52% of its in-sample return, 88% of windows made money out of sample, and 63% cleared the 50% bar. One window, Window 4, lost money: its efficiency of -23% drags the overall figure down. Had it earned 8% instead, the overall efficiency would have been 47%.
How to read the result
Overall versus median. The overall WFE compares average returns, so one disastrous window pulls it down hard. The median shows what a typical window did. When the two differ a lot, look at the window table: is the weak window a one-off event or the start of a trend?
Consistency. The share of windows above your threshold, and the share profitable out of sample, show whether performance is spread evenly or concentrated in a few lucky periods. A strategy that clears the bar in most windows is more trustworthy than one with the same average built on two outstanding windows. Raising the threshold to 60% in the example leaves only 13% of windows passing.
Why efficiency is below 100%. Optimization picks the parameter set with the best in-sample result, and part of that result is noise that happens to fit the period. That part does not repeat, so the in-sample return overstates what the parameters will earn next. Markets also change between windows. Some loss of performance is expected; the question is how much.
Absolute results. Efficiency is a ratio, so it can flatter a weak strategy: 4% in sample and 3% out of sample is a 75% efficiency on a return that may not cover costs. Judge the out-of-sample returns on their own as well, ideally as one stitched-together equity curve.
Walk-forward analysis and overfitting
Walk-forward testing guards against fitting one period, but it can be overfit itself. If you try many window lengths, re-optimization schedules and parameter ranges, and keep the combination with the best walk-forward result, the out-of-sample periods are no longer truly unseen. Count those choices as trials. The probability of backtest overfitting estimates how often the in-sample winner falls below the median out of sample, and the deflated Sharpe ratio adjusts a Sharpe ratio for the number of trials.
It also pays to look beyond returns: compare the drawdowns, win rates and trade counts in and out of sample. A strategy whose out-of-sample trades look nothing like its in-sample trades is behaving differently, whatever its efficiency.
What this calculator does not include
- Risk. WFE compares returns, not risk-adjusted returns. Two windows with the same return can carry very different drawdowns.
- Compounding across windows. Averages are arithmetic means of annualized returns, weighted by length if given; they are not the compound return of the stitched out-of-sample equity curve.
- Negative in-sample windows. Efficiency is undefined when the optimized in-sample return is zero or negative; those windows are excluded from the window-efficiency statistics but kept in the averages.
- Statistical significance. A handful of windows cannot prove skill. Use the out-of-sample returns with the Sharpe ratio calculator or a Monte Carlo trading simulation for a sense of the range.
- Costs. Enter returns after commissions, spreads and slippage, in and out of sample alike.