walk forward analysis gold grid
What Optimisation Actually Leaves You: A Walk-Forward Test of 25 Gold Grid Configurations
We rolled 25 grid configurations forward through 24 walk-forward folds on 663 months of gold, picking the best in sample each time and then running it on 60 months it never saw. The in-sample winner landed in the out-of-sample top quartile in 10 of 24 folds, and the mean rank correlation between the in-sample and out-of-sample rankings was negative on both monthly paths.
There is a specific way a backtest lies that is easy to miss, because it is not a coding error and it does not show up as a bug. The test runs. The numbers look reasonable. Nothing is inconsistent. And the result is still worthless, because the configuration you are looking at was chosen using the same data that produced the number you are looking at.
Everything written about overfitting in the last decade says this should batter you: Bailey, Borwein, López de Prado and Zhu’s probability of backtest overfitting, Harvey, Liu and Zhu’s multiple-testing cutoffs, White’s Reality Check. What those papers give you is a bound, a threshold, a p-value. What they do not give you is the size of the effect for a specific, ordinary, retail-scale optimisation.
So we measured it. The question is narrow and the answer is arithmetic: if you pick the best of 25 grid configurations on 240 months of gold, how much of that survives on the next 60 months?
The setup
The candidate set. Twenty-five configurations: spacing of 0.5%, 1%, 2%, 3% and 4%, crossed with 5, 10, 20, 30 and 40 levels. The set is not arbitrary — it contains all four configurations used throughout our published multi-account dataset (1%×20, 2%×10, 3%×10, 0.5%×40), so the reference point is a configuration that has already been published on this site.
The grid rule. A static anchor is set on the first bar of a segment. A level fills when price reaches it and closes at entry × (1 + spacing). Each level commits 10% of the current cash. A flat $0.30 per troy ounce round-turn cost is charged on every fill. When the grid closes fully above the anchor, the anchor resets.
The walk-forward. A 240-month in-sample window, then a 60-month out-of-sample window, stepping forward 60 months each time. Out-of-sample blocks never overlap, so the folds are independent. Every segment starts from a fresh state — equity 1.0, no open positions, no carried anchor — which is how a live account actually starts.
The selection rule. Highest in-sample CAGR. No judgement, no override, no “but I’d prefer a wider spacing”. This is the part that most people replace with discretion, and discretion is exactly what we wanted to measure without.
The price paths. Monthly averages from the World Bank’s Pink Sheet (663 months from August 1971) and daily LBMA PM benchmark fixes. The same simulator and the same cost model on both, so that the sampling-frequency effect documented on our grid backtest versus live price path page does not contaminate this one.
The eras. Free gold from August 1971 — the period after the $35 peg breaks, which includes the 1974 and 1980 shocks. And post-1980, which is the part of the sample that most retail backtests actually cover.
The result: the pick does not survive
On the monthly path of the free-gold era, across 7 folds:
| In sample | Out of sample | |
|---|---|---|
| The configuration the optimiser picked | +0.973% a year | +0.117% a year |
| Best possible out of sample (oracle) | — | +1.340% a year |
| Fixed 2% × 10 reference | — | +0.090% a year |
| Buy and hold | — | +7.613% a year |
The pick lost 0.856 percentage points a year between the data it was chosen on and the data it was scored on. And the gap between what it returned and what the best available configuration would have returned — the selection loss — was 1.222 points a year. On the post-1980 monthly path the selection loss was 1.652 points a year, and the pick’s average out-of-sample return was 0.211 points a year worse than just using the fixed 2% grid.
Three findings inside that table matter more than the headline.
The pick was usually not even good. It landed in the out-of-sample top quartile of the 25 candidates in 3 of 7 folds on the free-gold monthly path and 2 of 5 folds post-1980. Across all 24 folds, 10. A configuration chosen because it was the best available at the time was a below-median choice out of sample roughly half the time, and a top-quartile choice less than half.
More candidates beat it than it beat. The median fold had 10 of the 25 candidates returning more out of sample than the one selected in sample. The mean was 11.6. Picking the best of 25 on 240 months and then running it on the next 60 months produced a result that a random pick from the same set would have beaten most of the time.
The ranking did not carry over at all. The Spearman rank correlation between the in-sample ranking of all 25 candidates and their out-of-sample ranking averaged −0.122 on the free-gold monthly path and −0.081 post-1980. Both slightly negative. The configuration that looked best in sample was, if anything, marginally more likely than average to be a poor out-of-sample choice.
That last number is the one to sit with. A negative rank correlation is not what a weak-but-real edge looks like. A weak edge produces a small positive correlation. A negative correlation is the signature of nothing — the in-sample ranking is measuring the noise in that particular 240-month window, and where the noise happened to land.
Why it happens: the spread is noise
The mechanism is visible in the data. Compare the spread of results among the 25 candidates in sample against the spread out of sample:
| Era and path | In-sample spread | Out-of-sample spread |
|---|---|---|
| Free gold, monthly | 0.484 pp | 1.145 pp |
| Free gold, daily | 1.236 pp | 2.751 pp |
| Post-1980, monthly | 0.550 pp | 1.431 pp |
| Post-1980, daily | 1.150 pp | 3.085 pp |
The out-of-sample spread is two to three times wider than the in-sample spread, in every era and on every path. That is backwards from what a real edge would do: a genuine edge is a stable property of the strategy, so it should show up consistently across windows, not dissolve.
What it means is that the in-sample window was too narrow to identify anything. The candidates were much more different from each other on those 240 months than they turned out to be on the next 60 — but the difference was not signal, it was the particular shape of gold over that particular stretch. The optimiser did not find a good configuration. It found a configuration that happened to fit a noise draw, and it reported the fit as if it were the configuration.
This is exactly the failure White’s Reality Check was built to detect: the null hypothesis that the best model found in a specification search has no predictive superiority over a benchmark. Here the benchmark is the fixed 2% grid, and the answer the test gives is that the search did not beat it.
The one place it looked better
We should be as clear about the exceptions as about the rule, because a finding with no exceptions is a finding with a bug in it.
On the post-1980 daily path, the selected configuration returned +2.117% a year in sample and +4.330% a year out of sample — a negative decay of 2.213 points, meaning the pick did better than it had in sample. The mean rank correlation there was +0.180 and the median fold correlation was +0.864. The pick reached the out-of-sample top quartile in 3 of 5 folds, and the median fold had zero candidates beating it.
It is tempting to read that as “the daily path is better”. It is not. Five folds is five folds. The confidence interval on a mean Spearman of +0.180 computed from five observations is enormous, and the +0.864 median is sitting on a sample of three. More importantly, the mechanism is not mysterious: the daily path has roughly four times as many decision points per month, so it produces a wider out-of-sample spread (3.085 pp against 1.431 pp monthly). A wider spread means more opportunities for the worst candidate to look bad as well as for the best one to look good. Higher dispersion makes both tails more likely to contain an outlier — including the outlier in your favour.
We are not going to build a conclusion on five folds. We are reporting it because it is in the data, and because a study that only printed the unflattering rows would be the kind of study this site exists to criticise.
What the optimiser actually bought
Set the search against the two alternatives — do nothing clever, or just hold gold — and the scoreboard is not flattering to the search:
| Era and path | Pick beats fixed 2% grid | Pick beats buy-and-hold | Pick’s OOS CAGR | Fixed 2% OOS CAGR | Buy-and-hold OOS CAGR |
|---|---|---|---|---|---|
| Free gold, monthly | 3 / 7 | 2 / 7 | +0.117% | +0.090% | +7.613% |
| Free gold, daily | 5 / 7 | 3 / 7 | +1.837% | +1.383% | +7.642% |
| Post-1980, monthly | 3 / 5 | 0 / 5 | +0.574% | +0.785% | +9.566% |
| Post-1980, daily | 3 / 5 | 1 / 5 | +4.330% | +2.553% | +9.356% |
The search beat the fixed grid in 14 of 24 folds, which is above a coin flip but nowhere near what a real edge looks like. The average margin over the fixed grid was +0.027 points a year on the free-gold monthly path and −0.211 points a year post-1980 monthly. On one of the four paths the fixed configuration was ahead.
There is a second thing worth noticing in that table, which is not about the optimiser at all. Buy-and-hold returned 7.6% to 9.6% a year out of sample. Every optimised grid returned between 0.1% and 4.3%. The grid’s trade is real and is the reason grid results exist: the selected configuration’s average out-of-sample maximum drawdown was 9.51% against buy-and-hold’s 21.33% on the free-gold monthly path. You are giving up a great deal of return to cut the drawdown by more than half. That trade is worth making on its own terms. The optimiser’s contribution to it is not.
The limits, stated plainly
This is one historical price path per era, not a distribution of paths. Each era yields 7 and 5 folds, so the fold-level numbers carry real sampling uncertainty and the aggregate means are averages of small samples — read the rank correlations as “approximately zero”, not as a precise estimate of something.
“Out of sample” means out of the parameter-selection sample on that path. There is no broker statement, no server-side execution, no requote, no swap and no intraday path inside a daily bar, so none of this can be quoted as a live-versus-backtest result. Every in-sample and out-of-sample segment starts from a fresh state, which is closer to how a live account starts than a continuous backtest would be, but it also means each segment is a separate experiment rather than one continuous history. And no spread, slippage, financing, margin or tax is modelled beyond the flat $0.30 per ounce round-turn grid cost — though since costs are charged to both the in-sample and the out-of-sample leg, they are not what is producing the decay.
One more thing about the candidate set: 25 configurations is a modest search. Someone who ran 250 would find a bigger in-sample winner and, on this evidence, a correspondingly larger one. Nothing here suggests the search size is the reason for the result; it suggests the search itself is the reason.
What to do with this
If you are about to optimise a grid, the practical question is not “which parameters are best” — the data above says the answer you get from the optimiser is mostly a description of the window you optimised on. It is “which parameters should I fix in advance, and how do I check that the fix is not just a fit to noise?”
Three things follow from the numbers above.
Prefer a configuration you can justify structurally. The fixed 2% × 10 grid — wider spacing, fewer levels, lower funding requirement per rung — matched or beat the optimised pick on one of four paths. Its edge here is not that it is better; it is that you did not spend your edge on selection noise.
Test the selection, not just the strategy. If you have a parameter set, you can run the walk-forward yourself in an afternoon: pick the best of your candidates on the first 240 months, run it on the next 60, step forward, and count how often the pick lands in the top quartile. On this data, the answer was 10 out of 24. If your own version of that test comes back near half, the parameters are not doing anything and the strategy is carrying the result on its own merits.
Widen the in-sample window before you widen the candidate set. The in-sample spread was 0.48 to 1.24 points while the out-of-sample spread was 1.15 to 3.08 points. A window where the candidates look close together is a window that cannot tell them apart. If your candidates differ by less than the noise floor over your selection period, you are not choosing — you are rolling dice and then reporting the roll.
Reproducing it
The dataset is published as two CSVs: the fold table with one row per fold, and the full candidate table with every one of the 25 candidates scored in sample and out of sample in every fold.
The analysis script is scripts/gold_ea_param_decay_analysis.py. The
independent check is scripts/verify_gold_ea_param_decay.py, which
re-implements the grid simulator with a different internal structure,
re-derives the fold boundaries from the raw price files rather than from the
published dataset, and recomputes every per-fold CAGR, every aggregate and
every published CSV row from scratch. It runs 4,190 assertions.
The simulator itself is cross-checked against our published multi-account dataset: on the same 802-month sample it reproduces buy-and-hold at 7.399% a year with a −62.07% maximum drawdown (published: 7.399% and −62.07%), and the 2% × 10 grid at 1.116% with −36.26% over 129 fills (published: 1.117%, −36.26%, 129 fills). If the two implementations ever disagree, the build fails rather than publishing.
Related reading
- EA Backtest Traps: Overfitting, Look-Ahead Bias, and How to Prove It - the five other ways a backtest lies to you, and the statistics that catch them
- Why Your Grid Backtest Beats Your Live Account: Data Frequency, Not Strategy - the other half of the problem: what the sampling frequency of your price data does to the same grid, measured over 703 months
- Gold Grid Parameter-Selection Decay, 1971-2026 - the full dataset, every fold and every candidate, with the method and the independent recomputation
Read the full dataset page for every fold and every candidate, or the grid backtest versus live price path page for the other half of the story — what the sampling frequency of your price data does to the same grid.
Past performance does not predict future results. Nothing on this page is a recommendation to run any configuration, and no configuration described here is offered for trading. See the risk disclosure.
Frequently asked questions
How much of an optimised backtest survives out of sample?
On the monthly path since August 1971, the configuration an optimiser picked on 240 months of in-sample data returned 0.973% a year in sample but 0.117% a year on the next 60 months it never saw — a decay of 0.856 percentage points a year. On the post-1980 monthly path the same test gave 0.857% in sample and 0.574% out of sample.
Was the in-sample winner even a good out-of-sample configuration?
Usually not. It landed in the out-of-sample top quartile in 3 of 7 folds on the free-gold monthly path and 2 of 5 on the post-1980 monthly path. A median of 10 of the 25 candidates returned more out of sample than the one that had been selected.
Does the in-sample ranking carry information about the out-of-sample ranking?
Barely, and on the monthly paths it was slightly negative: mean Spearman correlation of -0.122 for the free-gold era and -0.081 post-1980. The in-sample winner was, if anything, slightly more likely than average to be a poor out-of-sample choice.
Does a fixed configuration do better than an optimised one?
About the same. On the free-gold monthly path the optimised pick beat the fixed 2%-spacing, 10-level grid in 3 of 7 folds, and the difference in average out-of-sample return was 0.027 percentage points a year — noise at this fold count. On the post-1980 monthly path the fixed grid was ahead by 0.211 points.
What are the limits of this analysis?
Four. It is one historical price path per era, not a distribution of paths. Each era yields only 7 and 5 folds, so fold-level numbers carry real sampling uncertainty. 'Out of sample' means out of the parameter-selection sample on that path — there is no broker statement, no requote, no swap and no intraday path inside a daily bar. And every segment starts from a fresh state, so each segment is a separate experiment rather than a continuous history.
Sources
- World Bank — Commodity Price Data (The Pink Sheet), monthly, updated November 3, 2026 — accessed 2026-11-18
- White, H. (2000) — A Reality Check for Data Snooping, Econometrica 68(5), 1097-1126 — accessed 2026-11-18
- Bailey, Borwein, Lopez de Prado & Zhu (2014) — The Deflated Sharpe Ratio, Journal of Portfolio Management 40(5), 94-107 — accessed 2026-11-18
- Harvey, Liu & Zhu (2016) — ... and the Cross-Section of Expected Returns, Review of Financial Studies 29(1), 5-68 — accessed 2026-11-18
- Bailey, Borwein, Lopez de Prado & Zhu (2015) — The Probability of Backtest Overfitting — accessed 2026-11-18
Use the free tools
Open-source calculators — no signup required.
Risk disclosure — read before acting on anything above
All content on this site is provided for educational and informational purposes only. Nothing published here constitutes investment advice, a recommendation, or an offer to buy or sell any financial instrument. Trading foreign exchange, CFDs, and precious metals involves a high level of risk and may result in the loss of your entire capital. Past performance of any strategy, robot, or expert advisor (EA) — whether simulated, backtested, or live — is not indicative of future results. You are solely responsible for your trading decisions. If you are unsure whether a strategy is suitable for you, seek independent advice from a licensed financial professional in your jurisdiction.