Backtest overfitting: how a winning manual backtest can still fool you
You changed the rule after seeing which trades lost, and the result improved. A worked example in R shows what that result can tell you, and what it cannot.

In short
Backtest overfitting means fitting a trading rule too closely to the historical data used to develop it, so its apparent success may not carry over to new data. Adding filters after seeing which trades lost is one way this can happen. In a hypothetical 20-trade test, removing six losers after the fact lifts the net result from +2R to +8.6R and the win rate from 40% to 57%, without one new trade. For a more honest test, write and date the rule before looking at outcomes, record every qualifying case, and try any revision on data you did not use to choose it.
A profitable backtest can come from editing the rules until enough losses disappear. You can do that with saved charts and a notebook, without writing a line of code.
Start with a breakout rule. After seeing the losing trades, you add a volume filter. One loss survives, so you exclude that sector. Another gets a special exception because the market “didn't look right.”
Every change may have a plausible explanation. But the final result comes from rules chosen with the answers already visible. That history helped you build the rule. It has not independently confirmed it.
01 · Backtest overfittingWhat does backtest overfitting look like in numbers?
Take a deliberately simplified, hypothetical test of twenty trades. Eight make +2R each and twelve lose −1R each. Here, R is one fixed unit of planned risk, the same unit we use in the guide to win rate and risk-reward. We assume those exact outcomes for the exercise, not for real executions.
The gross result is +4R. At an assumed cost of 0.1R per completed trade, the net result is +2R.
Now construct a filter after inspecting the outcomes. In this example it removes six losing trades and keeps every winner. The revised history shows +8.6R after costs.
| Hypothetical record | Original rule | Filter chosen after results |
|---|---|---|
| Trades included | 20 | 14 |
| Winners at +2R | 8 | 8 |
| Losers at −1R | 12 | 6 |
| Gross result | +4R | +10R |
| Assumed costs, 0.1R per trade | −2R | −1.4R |
| Net result | +2R | +8.6R |
The filter did not add a single winner, yet every headline figure improved:
The arithmetic is correct. What remains unknown is whether that filter helps on other trades. We deliberately built this example to remove losers. It is not a result from GB Capital, a real stock or a tested strategy.
Improving a rule is legitimate research. Reporting the improved sample as if the rule had been fixed beforehand overstates what you have learned.
02 · Manual backtesting mistakesWhy should you keep the rule versions you rejected?
In their paper The Probability of Backtest Overfitting, David Bailey and his co-authors explain why trying more alternatives on the same history increases the risk of selecting a false discovery. Keep a record of the attempted variations alongside the selected configuration.
For a manual test, keep each dated rule version. Record the change, why you made it and whether you had already inspected the outcomes. A volume threshold, a market filter and a new exit rule are separate research choices, even if they never appear in software.
If you tried twelve variations and show only the best, the reader cannot see the selection process. Neither can you when you return to the notes a month later.
03 · Lookahead bias in backtestingWhat is lookahead bias in a manual backtest?
There is a second problem. A chart can show information that was unavailable when the trade would have been decided.
For example, a filter using the session's final volume cannot justify an entry made that morning. You may use that figure for a later decision, once it exists. You cannot move it backwards in time.
TradingView's strategy-testing documentation calls the use of future information in a historical evaluation lookahead bias. It also distinguishes choosing favourable samples from fitting rules to a particular dataset. On saved charts, the three look like this:
| Error | What happens | On your saved charts |
|---|---|---|
| Lookahead bias | The test uses data that did not exist at decision time | A morning entry justified by that day's final volume or close |
| Selection bias | Only some stocks or periods are tested | You study the winners you remember and skip the rest |
| Overfitting | The rule is tuned to one set of past trades | Filters and exceptions added after seeing which trades lost |
For every input in your exercise, write when you could actually have known it. A good-looking setup needs an identifiable decision time.
04 · How to test a trading strategyHow do you test a trading strategy by hand before risking money?
- Write the rule before opening the test charts. Choose one setup you are studying. Include the eligible stocks, observation time, entry assumption, invalidation and exit condition. If the entry depends on a completed daily candle, say how and when an order could subsequently be filled.
- Fix the period and the stock universe first. Choose both before inspecting individual outcomes. Record every qualifying case under those rules, and the sessions with no qualifying setup too. Searching only for familiar winners answers a different question.
- Keep later prices out of view. Hide them while recording each decision. If you already know the outcome, mark that example as familiar. Do not describe it as an unseen test.
- Apply the same cost and execution assumptions throughout. If a daily candle touches both a hypothetical stop and target and you cannot establish which came first, record the ambiguity. Do not award yourself the favourable exit.
- Save any revision as a new version. When a case makes you want to change the rule, save the idea and finish recording the current version separately. Apply the revision to data not already used to select it.
Our guide to trading costs covers the items a clean chart can leave out. If the historical examples are already familiar, observe subsequent signals in simulation instead: the guide to paper trading explains what a demo account can and can't test. Retain the dated decisions in your trading journal.
This is a study exercise, not a statistical certificate. A small sample, a different market regime or repeated changes can still mislead you. Setting aside another period does not, by itself, establish a reliable edge.
GB Capital · Written swing trading course
Make the rule clear enough to question
The useful question to bring to a course is specific: “I can recognise this setup after the move. What exactly am I allowed to know when I make the decision?”
Our written swing trading course, The Operator's Playbook, covers market context, candidate selection, trade plans, position sizing and trade management. Work through one section with a dated chart and keep the decision you cannot explain. If you already own the course, bring the original example and rule to the included session.
one-time
05 · QuestionsFrequently asked questions
What is backtest overfitting?
Backtest overfitting means fitting a trading rule too closely to the historical data used to develop it, so its apparent success may not carry over to new data. Adding filters after seeing which trades lost is one way this can happen.
Can you overfit a manual backtest without writing code?
Yes. Adding a filter, excluding a sector or allowing an exception after looking at the losing trades changes the rule with the answers visible. Saved charts and a notebook are enough.
What is lookahead bias in a backtest?
Lookahead bias is using information in a historical test that was not available when the decision would have been made, such as the session's final volume for an entry taken that morning.
Is it wrong to change a rule after a backtest?
No. Improving a rule is legitimate research. Save the change as a new version and test it on data you did not use to choose it, instead of reporting the improved sample as a confirmation.
Does an out-of-sample test prove a strategy works?
No. A small sample, a different market regime or repeated revisions can still mislead. Bailey, Borwein, López de Prado and Zhu write that hold-out checks tend to be unreliable for investment backtests.
SourcesSources and further reading
- Bailey, Borwein, López de Prado and Zhu, The Probability of Backtest Overfitting, revised February 2015.
- TradingView, Pine Script documentation, Strategies: lookahead bias, selection bias and overfitting.
- GB Capital, Win rate vs risk-reward: the trading expectancy formula.
- GB Capital, Trading costs: commissions, spread and currency, explained.
- GB Capital, Paper trading: what a simulation can and can’t test.
- GB Capital, Trading journal: what to record, plus a free template.
Sources consulted on 19 November 2026. The exercise is our editorial proposal: it does not replicate the paper's CSCV method and does not measure a probability of overfitting. Educational content, not investment advice. The trade results above are hypothetical and do not represent actual trading. A real loss can exceed planned risk, and testing does not guarantee future returns.
