Appearance

Personalize your experience

Mode
Accent Color
Direction
Overfitting & Validation

Overfitting & Validation

Backtesting

Why searching for a good backtest reliably produces one even when no edge exists, how to recognise a fitted strategy, and the validation designs that actually protect against it.

The problem, stated precisely

Overfitting is not carelessness. It is the expected outcome of evaluating many configurations against one dataset and keeping the best. Even with no genuine edge anywhere in the search space, the best of twenty attempts will look good — because you selected it for looking good.

THE SAME TRAINING RESULT, TWO DIFFERENT STRATEGIESin-sample (tuned here)out-of-sample (never seen)splitrobustoverfittedboth look identical up to the split — which is why an in-sample result cannot tell them apartonly data the tuning never touched distinguishes an edge from a memorised history
Two strategies with identical in-sample results and opposite futures. Nothing in the training half distinguishes them.
!
Caution:The crucial implication: an result cannot distinguish a fitted from a real one. Not with better , not with a longer history, not with more care. Only that played no part in the selection can, and you can only spend that data once.

How much a search inflates a result

The arithmetic is worth internalising because it is more severe than intuition suggests. Testing n independent configurations and keeping the best gives you roughly the n/(n+1) quantile of the outcome .

Configurations triedTypeDescription
150th percentileAn honest sample. Whatever you got is what the does.
10~91st percentileThe best of ten looks noticeably better than the truth, and feels like a discovery.
50~98th percentileA parameter grid of this size will produce an impressive result from pure noise.
500~99.8th percentileAny grid search of this scale finds something excellent. The result carries no information at all.

And the count is larger than people think, because it includes everything you tried and discarded — every abandoned indicator, every threshold nudged, every timeframe checked. The search does not reset when you change approach.

★
Pro tip:Keep a written count of configurations tested. Not for rigour — for . Knowing you are on attempt forty changes how you read a good result, and that recalibration is the entire benefit.

Recognising a fitted strategy

Oddly specific parameters

(13) rather than RSI(14). A 2.7% stop. A 17-bar lookback. Real relationships are broad; is a fingerprint of search.

Many conditions

Five or more conditions each with a tuned threshold. Every one is a of freedom, and together they can describe any history.

Fragile to small changes

Rounding a parameter, or shifting the by a month, collapses the result. A genuine edge is insensitive to both.

Too few trades

A stellar over 25 . The metric is describing a handful of coincidences.

A flawless equity curve

Real strategies have ugly stretches. A with no meaningful across years is usually a leak or a fit.

Train and test disagree

The definitive symptom. Excellent , mediocre out-of-sample, is the signature.

ℹ
Note:The specificity tell is the most useful in practice because you can apply it without running anything. If a 's parameters look like they came from a search rather than from reasoning, they did — and the result should be discounted accordingly.

Validation designs

Three designs, in increasing strength. All of them work by reserving from the selection process; they differ in how much and how carefully.

Hold-out split

Split once, typically 70/30. Tune on the first part, evaluate once on the second. Simple, and strong provided you evaluate only once — every additional look at the test set converts it into training .

PropertyDescription
CostOne extra backtest run.
StrengthGood, and degrades with every re-evaluation.
Failure modeIterating against the test set. If you tune, check the test, adjust, and check again, you have simply used a slower route to overfitting the whole dataset.

Walk-forward

Several train/test windows. Each test slice is evaluated once, and agreement across windows is what constitutes evidence. Stronger than a single split because it tests whether the edge persists rather than whether it existed once.

ReadingDescription
Consistent across windowsTrain +25% / test +22%, repeatedly. The strongest signal available without trading.
Degrades in later windowsThe edge is decaying, or the market has changed. May still be tradeable, with .
Alternates good and badRegime-dependent. The works in one kind of market — identify which, and add a regime .
Uniformly poor out-of-sampleFitted. Simplify rather than re-tune; re-tuning is how you arrived here.

Out-of-sample instruments

Develop on one , validate on a different one with similar characteristics. This is a strong test because it holds the market structure roughly constant while changing the specific price history entirely.

★
Pro tip:A that survives on an it was never tuned for is unusually convincing. It is also the design most people never try, because it risks a result they would rather not see — which is exactly why it is informative.

Reducing the search space

The best defence is not better validation, it is fewer things to validate. Every constraint you impose before looking at is a constraint you cannot accidentally fit.

  • Fix parameters at conventional values. 14, SMA 50/200, 14. These were not chosen by fitting your , so they cannot be fitted to it.
  • Write the thesis first. A stated hypothesis makes the falsifiable and rules out the search-until-something-works loop.
  • Cap the condition count. Three or four. Each additional condition multiplies the space of strategies you could have arrived at.
  • Prefer numbers. A 3% stop rather than 2.7%. If the difference matters, the is fitted; if it does not, use the one.
  • Change one thing at a time. And record it. Undisciplined iteration makes the effective search count unknowable, and an unknowable count cannot be corrected for.

Related biases

BiasDescription
Look-aheadUsing information unavailable at time. Produces implausibly good rather than merely optimistic ones. Detect it with the prefix-stability test.
SurvivorshipTesting only instruments that still exist. The sample is the winners by construction, and every failure is missing.
SelectionChoosing the after seeing which one worked. Identical in effect to parameter overfitting, and easier to do without noticing.
RegimeA test containing one kind of market. Not overfitting exactly, but it produces the same false confidence.
PublicationBuilding on a published edge. Widely known relationships are usually arbitraged away, so a ’s result is unlikely to be your result.
!
Caution: deserves particular vigilance because it is the only bias that makes spectacular rather than merely flattering. Treat a above 3 or a above 80% as a bug report and go looking for the leak before accepting the result.

Before believing a strategy

  • A thesis written before any result was seen
  • Parameters at conventional values, not searched ones
  • Four or fewer conditions
  • A count kept of how many configurations were tried
  • Rounding the parameters does not change the outcome
  • Shifting the date does not change the outcome
  • Removing the best trade leaves it profitable
  • Walk-forward consistent across windows
  • The test set evaluated once, not iterated against
  • Validated on at least one it was not developed on
  • The can be stated as a sentence that predates the

See also

Related articles

  • Pitfalls & Anti-Patterns

    Automation / Strategy Builder / Reference

    The failure modes that show up repeatedly, what each one looks like from inside the builder, and the change that actually fixes it.

  • Walk-Forward Analysis

    Backtesting / Walk-Forward

    Walk-forward analysis repeats what deployment does: choose parameters on the past, trade them on a future they have not seen, move forward and choose again.…

  • The Backtesting Page

    Backtesting / Backtesting Page

    Automation → Backtesting runs any saved strategy or strategy file on the backtest engine, then lets you analyse, stress, optimize, validate, compare and…

  • Script Best Practices

    Coding / IDE / Best Practices

    Follow these guidelines to write performant, reliable, and maintainable trading scripts.

  • Step 7 — Strategy Testing

    Automation / Strategy Builder / Wizard Steps

    The testing step offers three modes, each answering different questions about strategy behavior. Use all three in sequence: backtest to validate logic,…

  • Writing DSL by Hand

    Coding / Strategy DSL

    Authoring strategy JSON directly: the minimum document, small constructors that keep it readable, validating before anything runs, generating variants, and…

  • Backtesting in Python and C++

    Backtesting / SDKs

    The quatick Python package and the header-only C++ library let you import indicators, backtest on your own machine and send the same file to Quatick.…

  • Backtesting Methodology

    Backtesting / Methodology

    What a backtest is actually evidence of, the assumptions built into it, how much data is enough, and the procedure that makes a result worth acting on.

  • C++ SDK Reference

    Backtesting / SDKs / C++

    Header-only C++20 (packages/quatick-backtest-cpp): the position simulator, an event-driven engine with the same order rules as Python, analytics, a parallel…

Browse all knowledge base articles →