A backtest that looks perfect should make you suspicious, not excited. Overfitting means tuning a strategy so closely to past prices that it fits the noise instead of a real pattern. The result looks excellent on the old data and fails on new prices. It is one of the most common reasons for the gap between a backtest and live trading, and the cleaner the equity curve, the more questions it deserves.
How overfitting happens
Imagine you test a simple rule and see a few losing trades. You add a filter to avoid them: skip Mondays, skip the hour after the London open, change the indicator period from 14 to 17. Each change removes a past loss, but it does so by memorising that history. The more settings you adjust, the more likely a good result is luck.
A helpful picture is a set of dials. Each setting you can change is a dial, and with enough dials and enough tries, some combination will fit the past, even on random data. The question is whether that combination has any reason to work tomorrow.

Warning signs
- A very smooth equity curve with almost no losing streaks.
- Many rules or settings for a simple idea.
- Results that collapse when you move one setting slightly.
- A great result built on a small number of trades.
- A strategy that works on one pair and one period only.
Two or three of these together should make you treat the result as unproven.
Ways to reduce the risk
Keep the idea simple, with few rules and few settings. Test on data you did not use for tuning, which is called out-of-sample testing. Check that nearby settings also work. If a 20-period setting is profitable but 19 and 21 lose, you may have found a lucky peak. Then run the rules forward on a demo account to see how they behave on live prices with real costs.

A safer testing process
- Write the rules first. Do not change them after seeing results without a reason you can explain.
- Split the data. Tune on one period and test on another that was not touched.
- Count the trades. More trades give a more reliable picture than a handful.
- Include costs. Spreads, commissions and slippage all reduce returns.
- Forward test on a demo, then go live with small size.
- Size from the stop. The position size calculator keeps risk fixed in every test and in live trading.

Illustrative example: a fragile peak
A trader tests a moving average period and records these profit factors: period 18 gives 0.9, period 19 gives 1.0, period 20 gives 3.4, period 21 gives 0.8 and period 22 gives 0.9. Only period 20 looks great, and its neighbours do not. That is a lucky peak, not a stable edge. The trader goes live anyway with a $3,600 account and sells EUR/USD at 1.0560, with a stop at 1.0596 (36 pips) and a target at 1.0488 (72 pips). Risk is 1%, or $36.
Position size: $36 / (36 pips x $10 per pip per lot) = 0.10 lot.
The signal fails on live prices and the stop is hit. Result: 0.10 lot x 36 pips x $10 = $36 loss. One losing trade proves nothing, but a record full of fragile peaks would.
Illustrative example: a plainer system that holds up
A second trader uses a two-setting breakout rule that gives profit factors of 1.2 to 1.4 across a range of settings, and about 1.3 on a later period not used for tuning. It is less exciting and more believable. On a live account of $18,000 they buy GBP/USD at 1.2905, with a stop at 1.2873 (32 pips) and a target at 1.2969 (64 pips). Risk is 0.5%, or $90.
Position size: $90 / (32 pips x $10 per pip per lot) = 0.28 lot.
The trade reaches its target. Result: 0.28 lot x 64 pips x $10 = $179.20. Going live small checks the result on prices that the backtest never saw.
Why a simple strategy is not a cure
Fewer rules reduce the risk, but they do not remove it. You can still overfit a simple idea by testing hundreds of variations and keeping the best one. A good habit is to keep a record of how many versions you tried. If you tested fifty settings and picked the best, expect its result to fade. Another useful check is to ask why the rule should work: an idea with a logical reason, such as a known session behaviour, is less likely to be pure noise than one found only by searching. The glossary defines terms such as out-of-sample and profit factor.
Common mistakes
- Adding a rule to fix each past loss. This memorises history. Add a rule only if you can explain why it should work.
- Tuning and testing on the same data. You have no fresh test left. Hold back a period.
- Trusting a high result from a small sample. Few trades can look great by luck. Collect more.
- Skipping the demo test. Live feeds and costs behave differently. Run it forward first.
- Ignoring costs in the test. A thin edge can vanish after spreads. Include them from the start.
Pre-trade checklist
- Did I write the rules before testing?
- Did I test on data that I did not use for tuning?
- Do neighbouring settings also work?
- How many trades are in the sample?
- Are costs included?
- Have I run it on a demo before risking real money?
Frequently asked questions
What is overfitting in trading?
Tuning a strategy so closely to past prices that it fits noise, which makes it fail on new data.
How can I tell if a backtest is overfitted?
Warning signs are many rules, very high results and sharp drops when settings or periods change.
What is out-of-sample testing?
Testing the rules on data that was not used to build or tune them.
Does a simple strategy avoid overfitting?
It lowers the risk, though you still need tests on new data.
Nothing in this overfitting guide is financial advice; it is written for education only. Trading carries risk, and a good backtest does not predict future results. The overfitting numbers are invented for illustration.



