Testing and analysis

Backtest Overfitting: How to Spot It and Reduce the Risk

Published ForeXpert team日本語で読む

Backtest overfitting happens when rules are adjusted too closely to a particular historical sample and fail to work similarly on other data. Adding an exception after every losing trade can make the same record look better without creating a rule that generalizes.

This guide explains how overfitting can appear in manual trading and how to structure a more useful test. Separate the data used to develop a rule from the data used to check it unchanged, and keep a record of all the versions you tried.

What backtest overfitting means

QuantConnect's research guide describes overfitting as tuning to the detail and noise of historical data in a way that harms performance on new data. It is not limited to optimizing an automated strategy's parameters.

Manual traders can do the same thing with verbal conditions. After seeing the result, “avoid this shape” or “skip that hour” becomes another exception. Because discretionary language has flexible boundaries, the trader may not notice that the rules changed.

Pattern How rules change What to investigate
Hypothesis-led improvement State the reason before testing Does it remain meaningful elsewhere?
Outcome-led exceptions Add a filter after a losing example Does it only erase losses already seen?
Ambiguous relabeling Reclassify a setup after its outcome Was the classification possible at entry?

Changing a rule does not automatically mean it is overfit. But improved performance on the data used to choose the change cannot, by itself, establish that the change is useful more generally.

Common examples of overfitting

Adding exceptions one loss at a time

Consider a fictional development process. A trader removes the weekday with the most losses, then removes a particular hour and candle shape. Those changes may improve the same record, because the conditions were selected after the outcomes were known.

The unanswered question is whether those conditions actually explain the losses or merely happened to coincide with them in that sample. Evaluating only the data that suggested the filters cannot settle that question. It rewards matching the history already examined.

Keeping only the best trial

If you test several stop distances and exit conditions but preserve only the best version, the number of candidates disappears from view. More candidates create more opportunities to select something that looked good by chance.

Keep rejected versions and the reason for rejecting them. A result is easier to interpret when you can see the whole development process rather than only its winner. A clean final rule does not reveal how many alternatives were tested before it.

Depending on one exact setting

If one parameter value produces an exceptional result and nearby values perform much worse, investigate why that exact value was selected. Checking nearby settings can reveal a narrow dependency.

However, stable neighboring settings do not prove safety. Repeatedly searching parameter neighborhoods can itself become another optimization exercise. Define the question and the range to examine before looking at the results, rather than extending the search until something looks reassuring.

Four steps to reduce overfitting risk

Four steps: write a hypothesis, separate development and validation periods, record every trial and freeze rules during validation
Diagram: A process for reducing overfitting risk

1. Write the hypothesis before checking results

Describe what the change is supposed to address and why it should matter. Ask whether the decision can be made using information available at entry. A filter that only makes sense after the trade is complete cannot be applied honestly in a new test.

See the look-ahead bias examples to audit information timing. If a condition uses a higher chart, the multiple timeframe practice routine explains how to fix its role and candle-confirmation rules.

If you cannot explain an exception, pause before adding it. Also check whether the original losses came from breaking the existing rules. A new strategy condition may not solve an execution problem, and it can make the rule harder to follow.

2. Separate development from validation

Data used to create and adjust rules is commonly called in-sample. Data held back for checking the fixed rules is out-of-sample. For a manual test, you might develop on an earlier period and reserve a later period that you have not examined.

There is no universally correct split. Both portions need enough opportunities and meaningful time coverage. QuantConnect's backtesting documentation also describes preserving an out-of-sample period for testing after development.

Data role Appropriate use Main caution
Development Test hypotheses and clarify rules Record all attempted versions
Validation Apply the chosen rules unchanged Do not add filters after seeing outcomes
Fresh later data Check a revised version again Previously reviewed validation is no longer unseen

A separate calendar period is helpful only when its information has genuinely been kept out of the development decisions. If you already know the chart or selected the split because it gave good results, document that limitation.

3. Freeze and record the rule version

Write entry, stop, exit and exclusion conditions before starting. Add a version number or date. When a borderline setup appears, record the ambiguity rather than deciding that it did not qualify after discovering that it lost.

Keep costs and sizing consistent as well. Otherwise, a supposed strategy improvement might simply come from removing costs or taking larger positions. Our trading-journal review guide explains how to organize the record around a specific improvement.

A useful change log states the old condition, new condition, reason, development period and next validation period. It does not need to be long; it needs to make the sequence of decisions visible to a later review.

4. Do not rewrite validation results

If validation performs poorly, do not add an exception and present the recalculated version as if it were the original unseen test. You may revise the rule, but the period has now contributed to development.

The revised version needs a fresh check. Repeatedly reviewing a holdout lets its information influence the rule, even if the period still has a “validation” label. Preserve the original result and distinguish it from any later research on that data.

A checklist for interpreting the results

At the end of a test, ask:

  • Can I explain what changed and what stayed fixed?
  • Did I record rejected trials as well as the chosen version?
  • How many trades are in development and validation separately?
  • Does profit depend on one trade or one short episode?
  • Were costs and sizing treated consistently?
  • Did any setup classification change after its result was known?

Review average outcome, profit factor and drawdown as well as win rate. Searching for the best version across an expanding set of metrics is still a selection process, however. Decide which question and measures matter before using them to choose a winner.

ForeXpert supports bar-by-bar historical practice and post-trade statistics. Combine that decision-time discipline with your own rule-version log. The app's chart controls cannot by themselves prevent a trader from changing the rules after seeing results.

The ForeXpert chart screen for practicing without revealing future candles
ForeXpert chart screen (demo data)

Frequently asked questions

If another period is profitable, does that rule out overfitting?

No. Check whether the period was reviewed repeatedly or whether many candidates were tested before one favorable result was selected. Backtest results do not guarantee future performance. Validation is a way to investigate weaknesses, not to eliminate uncertainty.

Are simple rules always better?

Fewer conditions are often easier to explain and execute, but simplicity alone does not establish usefulness. The conditions need a reason, must be reproducible using information available at the time, and must be applied consistently to data not used to create them.

What is walk-forward testing?

It repeatedly moves a development window and a subsequent unchanged-rule evaluation window through time. This can reduce dependence on one historical split. But repeatedly selecting window designs to improve the final score can still introduce selection bias, so the evaluation design also needs discipline.

Summary

To reduce overfitting risk, write the hypothesis first, separate development and validation, preserve the trial history and keep rules fixed during the check. Any revision based on the validation result requires another fresh evaluation.

Start by versioning your current rule and deciding which data will serve which role. The five-step backtesting guide explains how to carry out the historical practice itself.