How to run realistic backtests and avoid overfitting
A smooth equity curve is easy to admire. The harder question is whether the result survives realistic costs, unseen data and a close inspection of how the trades were simulated.
A backtest asks what a set of trading rules would have done on historical data under specified assumptions. It helps investigate an idea. It does not establish what your account will earn. The NFA explains why hypothetical results can misrepresent liquidity, slippage and the experience of taking real financial risk.
The standard to aim for
A useful backtest is reproducible, shows its costs and limitations, and survives attempts to disprove the idea. A profitable historical result alone is insufficient.
1. Start with a test someone else could reproduce
Write down the trading idea before searching for attractive settings. What behavior is the strategy trying to exploit? When should that behavior disappear? A rule with a clear explanation is easier to challenge than a collection of exceptions added after each losing trade.
Keep a research record with:
- Rules and version: entries, exits, position sizing, trading hours, stops and the exact code or configuration.
- Data: source, instrument, contract, date range, time zone, bar or tick resolution, missing data and session boundaries.
- Account assumptions: starting capital, contract quantity, leverage, margin constraints and whether sizing compounds.
- Execution: order types, fill timing, commissions, exchange and clearing fees, spread, slippage and any liquidity limits.
For futures, record the contract-roll schedule and whether the price series is adjusted. A continuous chart is not itself a tradable contract. For an instrument universe, include assets that disappeared rather than selecting only today's survivors. Use information available at the historical decision time. These are forms of the data-selection and look-ahead problems that can make an impossible strategy look convincing.
2. Include commissions and slippage from the first run
Reconcile total trading profit and loss before costs with the net result after costs.Some reports use “gross profit” for winning trades only; include losing trades too. Confirm whether a fee is per contract, per side or for a complete entry-and-exit round trip. A two-contract round trip pays costs on both contracts and both sides.
Slippage is the difference between the assumed reference price and the execution price. In testing, use an explicit adverse allowance appropriate to the order, instrument, size and conditions. A liquid afternoon and a fast news release should not automatically receive identical assumptions.
A small cost assumption can change the whole result
Consider an invented set of 100 round trips, one E-mini S&P 500 futures contract per trade, with $4,000 total pre-cost profit across winners and losers. CME specifies $12.50 per ES tick. Assume $5 in total commissions and fees per round trip solely for this illustration.
| Assumption | Pre-cost P&L | Fees | Slippage | Net |
|---|---|---|---|---|
| No costs included | $4,000 | $0 | $0 | $4,000 |
| 1 adverse tick each side | $4,000 | $500 | $2,500 | $1,000 |
| 2 adverse ticks each side | $4,000 | $500 | $5,000 | −$1,500 |
1 tick × 2 sides × $12.50 × 100 trades = $2,500 slippage
$4,000 − $500 − $2,500 = $1,000 net
This simple deduction holds the hypothetical trades fixed. Rerunning an execution-aware simulation is stronger: different fills can change stops, exits and later trades. If spread or slippage is already included in simulated fill prices, avoid charging the same effect twice. List every included and excluded cost so another reader can reconcile the numbers.
3. Separate in-sample development from out-of-sample testing
In-sample data is history used to develop rules, select indicators or tune parameters. Out-of-sample data is history excluded from those decisions. A profitable result on data used to design the strategy is a development result, not an independent test.
| Period | Purpose | Allowed decisions |
|---|---|---|
| Months 1–18 | In-sample development | Build rules and explore parameters. |
| Months 19–24 | Validation | Compare candidates. Once used for selection, this is part of development. |
| Months 25–30 | Final out-of-sample holdout | Evaluate the frozen choice. Do not tune against these results. |
Choose boundaries before inspecting results. The example is not a recommended universal ratio: enough independent trades, market conditions and useful history matter more than a neat percentage. Keep time moving forward. Time-series validation avoids training on later observations and testing on earlier ones. When outcomes or trades overlap a boundary, separate them appropriately so future information cannot leak backward.
If the holdout disappoints and you change the strategy to fix it, that period has become development data. You need fresh evidence. This includes asking AI to improve a strategy after showing it the holdout results. Research on adaptive holdout reuse shows why repeatedly consulting a test set can overfit the test itself.
4. Recognize what overfitting looks like
Overfitting happens when rules capture accidents in a particular history rather than a relationship that generalizes. Testing thousands of combinations makes it easier to find a spectacular historical winner by chance. Changing the instrument, start date or trading session until the chart looks better is also a search decision.
Keep the full experiment count, including failed ideas and AI revisions. The winner of 5,000 searches carries different evidence from one rule specified in advance. Bailey and colleagues' backtest-overfitting research explains why a holdout alone does not account for all selection risk.
- Check neighboring parameter values. An isolated profitable setting surrounded by losses deserves investigation.
- Compare different chronological periods and relevant market conditions without selecting only the favorable slices.
- Prefer a simpler explanation when added filters improve only the development period.
- Record sensitivity tests before seeing final holdout results; do not keep redefining what counts as a pass.
None of these checks certifies a strategy. For a large search, selection-aware statistics such as the Deflated Sharpe Ratio can add context, subject to their assumptions. A high Sharpe ratio reported without the research history is incomplete evidence.
5. Walk forward without peeking
Walk-forward testing repeats a procedure through time: fit on an earlier window, freeze the decision, and test on the next window. Move forward and repeat using only information that would then have existed.
Fit months 1–12 → test months 13–15
Fit months 4–15 → test months 16–18
Fit months 7–18 → test months 19–21
This is an illustrative rolling schedule. Predefine the window lengths, search budget, selection rule, retraining frequency and cost model. Combine the non-overlapping forward test windows in date order, including weak windows and any costs of changing positions. Keep a separate final holdout when you use walk-forward results to choose the overall procedure.
A window tested once is useful evidence; a window repeatedly used to redesign the process is no longer untouched. Also distinguish this historical exercise from forward paper trading, which observes new incoming data. Neither guarantees live results.
6. Challenge how the simulated fills happened
A signal and a fill are different events. Fill models specify execution prices and quantities; their assumptions can materially change the result. Inspect several individual trades instead of relying only on a summary.
- Close-based signals: a decision requiring the completed bar cannot automatically receive an earlier price from that bar. Check when the order actually becomes eligible.
- Stop and target in the same bar: OHLC data alone may not reveal which price came first. Use suitable finer data or disclose a conservative ambiguity rule.
- Limit-order touches: touching a price does not establish that your order had queue priority or sufficient opposing volume to fill.
- Size and speed: review partial fills, latency, available liquidity, rejected orders and adverse movement during fast conditions.
Higher-resolution data can answer more questions, but it does not recreate your historical queue position. Also check for indicators that repaint past signals, future-dependent labels, and models trained on the full dataset before it was split. An out-of-sample label cannot repair an execution or information-timing error.
7. Read the risk behind the profit
Review results net of the stated costs and alongside the capital and exposure required. A larger dollar profit obtained by multiplying contract size is not evidence of better rules. Keep sizing comparable across candidate tests.
- Drawdown: inspect the equity curve including open-position losses, the worst peak-to-trough loss, and time spent below the prior high. Historical maximum drawdown is not a limit on future losses.
- Average net trade: compare the remaining profit per trade with the uncertainty in your cost assumptions.
- Distribution: look at losing streaks, the largest loss, typical wins and losses, and whether a few trades explain most of the profit.
- Coverage: report trade count, test duration, exposure, and results across periods. Closely clustered trades may provide less independent evidence than their count suggests.
- Concentration: stress-test dependence on the best trades or strongest month, and show the original result alongside the stress test.
A 90% win rate can still lose money if occasional losses are large. There is no universal trade count, profit factor or Sharpe threshold that turns a backtest into proof.
8. Spot misleading or potentially fake backtests
An omitted assumption does not establish deliberate fraud. It does mean the result needs more evidence. Ask for a reproducible report before buying a strategy or relying on its advertised performance.
| Warning sign | Evidence to request |
|---|---|
| Profit with no cost settings | Gross-to-net reconciliation, per-side fees, contract quantities, and spread/slippage assumptions. |
| Only an equity-curve screenshot | Timestamped trade-level records, settings, capital assumptions and a repeatable run. |
| Perfect-looking fills | Order timestamps, data resolution, same-bar handling, liquidity limits and fill-model documentation. |
| A hand-picked winning period | Full declared date range, losing periods, selection history and the reason for any exclusions. |
| “Out of sample” after repeated revisions | A dated record of when rules were frozen and what data was consulted during selection. |
| Simulated results presented as live | Clear labeling and independently verifiable broker records for any live-performance claim, with deposits and withdrawals reconciled. |
A polished report, AI-generated explanation or impressive win rate cannot authenticate the underlying trades. Even verified past live results do not establish what happens next. Treat guaranteed-return claims as a reason to stop and investigate.
9. Use a workflow you can repeat
- Specify the idea. Record rules, sizing, data, trading hours and the conditions under which you would reject the hypothesis.
- Define the experiment. Reserve chronological development, validation and final test periods. Set the search budget and evaluation criteria in advance.
- Audit the mechanics. Inspect individual trades and confirm information timing, contract handling, fees and the fill model.
- Develop and stress-test. Track all trials. Examine neighboring settings, adverse costs, different periods and concentration without consulting the final holdout.
- Freeze and evaluate. Save the exact version, then run the final test and report it with the development results. Keep a failure in the record.
- Observe forward behavior. Paper trade on new data and compare signals, fills and costs against the assumptions. Paper fills still have limitations.
- Keep monitoring. If you later choose live trading, use exposure limits appropriate to the risk you can bear. Track divergence and predefined stop conditions; a successful backtest does not remove trading risk.
Before you trust the chart
Can you reproduce the result, reconcile it after costs, explain every fill assumption, and show evidence that was not repeatedly used to select the strategy? If any answer is missing, the research is unfinished.
Sources and further reading
The workflow and numerical example above are editorial guidance. These primary sources explain the underlying limitations, research methods and contract specification.
- NFA: hypothetical performance and its limitations.
- CME Group: E-mini equity index contract tick values.
- Bailey, Borwein, López de Prado and Zhu: The Probability of Backtest Overfitting.
- Bailey and López de Prado: The Deflated Sharpe Ratio.
- Dwork and colleagues: Generalization in Adaptive Data Analysis and Holdout Reuse.
- scikit-learn: time-ordered train/test splitting.
- QuantConnect: fill-price and quantity modeling; research biases and information timing. These describe that engine's behavior, not a specification of HyperionX's execution model.