Research question
Using a simulated 300-month return series, the article searches 500 parameter sets over the first 180 months, treats the middle 60 months as the first out-of-sample window and the last 60 as the final holdout. How much of the best in-sample result survives out of sample? What happens if the analyst reuses the middle 60 months to select a model? The data are generated with seed 20261036 and are not real market data.
Data
| Item | Value |
|---|---|
| Total sample | 300 months |
| Frequency and unit | monthly returns; Sharpe is unitless |
| Search period | first 180 months |
| First out-of-sample window | middle 60 months |
| Final holdout | last 60 months |
| Parameter sets | 500 |
| Best in-sample Sharpe | 0.831 |
| Its first out-of-sample Sharpe | 0.072 |
| Mean out-of-sample Sharpe of the in-sample top 10 | -0.002 |
| Correlation of in-sample and out-of-sample Sharpe | -0.061 |
| Best Sharpe after 20 out-of-sample selections | 1.131 |
| Final 60-month Sharpe of that 1.131 combination | 0.489 |
| License | simulated data, no external license |
Method and assumptions
The strategy uses 500 parameter combinations of one signal (lookback and holding period). The in-sample window selects the combination with the highest Sharpe; the first out-of-sample window is evaluated once. A separate exercise has an analyst select 20 times on the middle 60 months, report the best Sharpe, and test that combination on 60 untouched months. Sharpe is the monthly mean divided by the standard deviation, then multiplied by √12, with no costs deducted. The first out-of-sample window does not enter the first selection; reusing it 20 times turns it into selection data. Overfitting means treating in-sample noise as signal. NIST/SEMATECH notes that a single fit statistic does not prove a model is adequate, while Chicco and Jurman (2022) state that a test set must not be used repeatedly, because doing so causes overfitting and invalidates the results [2].
Results
The best in-sample Sharpe is 0.831, versus 0.072 in the first out-of-sample window; the in-sample top 10 average -0.002 out of sample, and the in-sample/out-of-sample correlation is -0.061. After 20 out-of-sample selections, the best reported Sharpe is 1.131; the same combination scores 0.489 over the final 60 months, a shrinkage of about 57%.
Diagram: two markdowns
Robustness
- This run fixes one split, 180/60/60: other splits or seeds change the numbers, while the overestimation from taking the maximum of 500 in-sample values follows from the selection mechanism itself, not from one draw. Stating results for a 150/75/75 split would require extending the script's parameters and running it, which this article does not do.
- This article deducts no trading costs and reports no turnover by parameter set; directionally, costs accumulate with turnover, so net Sharpe falls once they are deducted and falls most for the shortest holding periods. The quantified version is in the main article Survivorship Bias and Trading Costs (RES-021).
Limitations
One simulated series is not a real asset; the grid, split points and strategy family are arbitrary. Sharpe estimates are shown without standard errors, and the final 60 months could be unusually high or low. Costs, capacity and regime change are omitted. Reusing the same out-of-sample data turns it into in-sample data in practice; a true final holdout is used once. OpenStax notes that extrapolation beyond the observed range is unreliable even when an equation produces a number; the 60-month holdout cannot be extrapolated to longer periods. Out-of-sample evaluation and cross-validation apply only when a budget of untouched data is reserved, when time-series folds are split in time order so that no future information leaks, and when each fold is used for a single evaluation - re-selecting on the same fold turns it into training data. The same source limits their value: a single out-of-sample estimate is itself noisy and is reported here without standard errors, shorter holdouts are less reliable, and performance outside the tested window cannot be inferred from it. The correlation is computed over all 500 combinations (restricting it to the in-sample top ten gives 0.089), so the figure is basis-dependent, while the near-zero relation between in-sample rank and out-of-sample result holds on either basis. The evidence does not support any forecast of a real strategy's return.
Reproduction
- Generate 300 monthly returns with seed 20261036.
- Enumerate 500 lookback and holding-period combinations.
- Select the best Sharpe over the first 180 months and evaluate it on the middle 60.
- Simulate 20 out-of-sample selections and record the best Sharpe.
- Evaluate the same combination on the final 60 months and report the results.
node scripts/simulate-out-of-sample-overfitting.mjs --check
seed = 20261036
months = 300; search = 180; oos = 60; final = 60
grid = 500; best_is_sharpe = 0.831; best_oos_sharpe = 0.072
top10_oos_mean = -0.002; corr_is_oos = -0.061
best_after_20_oos_picks = 1.131; final_sharpe = 0.489
Strength of conclusions
The best in-sample value is the maximum of 500 comparisons and contains selection bias; it does not carry over out of sample. Reusing the out-of-sample window brings that bias back. The evidence supports "set aside a final sample and evaluate it once"; it does not support treating 0.831 or 1.131 as achievable; the holdout reading of 0.489 is itself one noisy draw.
Related
- Required prerequisite: Backtesting and Look-Ahead Bias (RES-020).
- Related reading: Rolling Analysis and Structural Change (RES-018), Backtesting and Look-Ahead Bias (RES-020), Multiple Testing and Data Snooping (RES-023).
Figures in plain language
The three figures below check the mechanism, boundary and comparison in this article; labels come from its own sections, not new data.
Exercises
- Why does the best in-sample Sharpe overstate skill?
- What is the point of evaluating out of sample only once?
- Why is 1.131 not credible after 20 out-of-sample selections?
- Does overfitting occur only when there are many parameters?
Suggested answers
- The maximum of 500 noisy estimates tends to select positive noise, so it exceeds true skill.
- It keeps the out-of-sample window from participating in selection and preserves a relatively independent test.
- 1.131 is the maximum of 20 selections made on the same out-of-sample window; the final holdout gives only 0.489, so the reported figure was inflated by about 57%, while a single holdout is itself a noisy estimate rather than a new constant.
- No; repeatedly looking at the same data, changing rules or choosing the sample window can also turn noise into a signal.
Sources
- NIST/SEMATECH. e-Handbook of Statistical Methods, “4.4.4 How can I tell if a model fits my data?” U.S. Government work (public domain). https://www.itl.nist.gov/div898/handbook/pmd/section4/pmd44.htm (accessed 2026-10-30)
- Chicco, Davide, and Giuseppe Jurman. “The ABC recommendations for validation of supervised machine learning results in biomedical sciences.” Frontiers in Big Data 5 (2022): 979465. CC BY 4.0. https://www.frontiersin.org/journals/big-data/articles/10.3389/fdata.2022.979465/full (accessed 2026-10-30)
- OpenStax. Introductory Statistics 2e, “12.5 Prediction.” CC BY-NC-SA 4.0. https://openstax.org/books/introductory-statistics-2e/pages/12-5-prediction (accessed 2026-10-30)
Worked demo
Read-through check: can you say three things?
No recitation needed. Tick each sentence below and see whether you can explain the mechanism, one worked example and one boundary in your own words.
Ticked 0 / 3
The numbers are teaching assumptions that show relationships, not forecasts or investment advice.
This article has passed the current publication gate. Factual, calculation and translation revisions update both language versions together.