Optimising vs Overfitting: The Hidden Danger in Backtesting

Estimated reading time: 10–12 minutes
Category: Trading Strategy / Backtesting
Audience: Beginner to intermediate part-time traders building a structured approach to stocks, forex, indices, commodities, or crypto.


Introduction

Backtesting can be one of the most useful tools in trading.

It allows you to study how a strategy might have performed in the past. It helps you collect examples, spot weaknesses, understand market behaviour, and build confidence before risking real money.

But backtesting also has a hidden danger.

A strategy can look excellent in historical data and still fail badly in live markets.

Why?

Because the trader may not have built a strong strategy. They may have built a strategy that fits the past too perfectly.

This is the difference between optimising and overfitting.

Optimising is useful. It means improving a strategy in a logical, controlled way.

Overfitting is dangerous. It means adjusting a strategy so closely to past data that it loses its ability to work in new market conditions.

At first, the difference can be hard to see. Both can make a backtest look better. Both can improve historical results. Both can make a trader feel more confident.

The problem is that only one is healthy.

In our previous guide, Why Most Trading Strategies Fail Over Time, we looked at why strategies stop working, including market changes, execution drift, weak risk management, and poor review habits.

Now we are looking at one of the most common reasons a strategy fails before it even reaches live trading: it was overfitted during the testing stage.

This guide explains the difference between optimisation and overfitting, how traders accidentally fool themselves with backtesting, and how to build a more realistic testing process.


Who This Is For

This guide is for you if:

  • You are learning how to backtest a trading strategy.
  • You have adjusted strategy rules until the results looked better.
  • You are unsure whether your backtest is realistic or too perfect.
  • You want to avoid building a strategy that only works on past data.
  • You trade part-time and need a practical way to test without overcomplicating the process.
  • You want to build strategies that are clear, measurable, and more robust.

This is not for traders looking for a perfect system or guaranteed results.

Stocked & Shared focuses on practical trading education. Backtesting is useful, but it is not a crystal ball. The goal is not to create a perfect historical result. The goal is to understand whether a strategy has a sensible edge that may survive real market conditions.


What Is Backtesting?

Backtesting is the process of applying a trading strategy to historical market data to see how it would have performed.

A trader might look at past charts and record every time their setup appeared. They may track entries, stop-losses, targets, winners, losers, drawdowns, and overall performance.

Backtesting can help answer questions such as:

  • How often does this setup appear?
  • What type of market does it work best in?
  • Where does it fail?
  • What is the average winner?
  • What is the average loser?
  • How many losing trades can happen in a row?
  • Does the reward justify the risk?
  • Are the rules clear enough to repeat?

Used properly, backtesting helps traders move away from guesswork.

It gives structure.

But backtesting has limits.

Historical data is already known. Live trading is uncertain. When looking backwards, it is easy to see the clean setups and ignore the messy ones. It is easy to adjust the rules after knowing what happened next.

That is where the danger begins.

A backtest should help you learn. It should not become a way to convince yourself that a weak strategy is stronger than it really is.


What Is Optimisation?

Optimisation is the process of improving a trading strategy by making logical changes based on evidence.

For example, a trader might test whether a strategy performs better when:

  • It only trades during trending conditions.
  • It avoids major news events.
  • It uses a wider stop-loss.
  • It targets the next support or resistance level.
  • It trades only liquid markets.
  • It avoids low-volatility periods.
  • It uses a higher timeframe filter.

These are reasonable adjustments if they are based on market logic.

Good optimisation asks:

Does this change make the strategy more practical, more robust, or easier to execute?

It does not simply ask:

Does this make the backtest look better?

That difference matters.

A useful optimisation should make sense before you see the result. It should be connected to how markets behave.

For example, if a breakout strategy struggles in choppy markets, adding a trend or volatility filter may be logical.

If a mean reversion strategy performs poorly during strong trends, adding a market condition filter may be sensible.

If a stop-loss is too tight and keeps getting hit by normal market noise, testing a slightly wider structure-based stop may be reasonable.

Optimisation is not about chasing perfection.

It is about improving clarity, risk control, and consistency.


What Is Overfitting?

Overfitting happens when a strategy is adjusted too closely to past data.

Instead of finding a rule that makes sense, the trader keeps changing settings until the historical performance looks impressive.

The strategy becomes highly customised to the exact market moves that already happened.

It may look strong in a backtest, but it struggles when conditions change.

A simple example:

A trader tests a moving average strategy.

They try the 20-period moving average. Results are average.

They try the 21-period moving average. Slightly better.

Then 22. Then 23. Then 24.

Eventually, they find that the 37-period moving average produced the best historical result on one market over one specific period.

They build the strategy around that setting.

But why 37?

Is there a strong market reason? Or did it simply fit that historical sample best?

That is the problem.

The trader may not have discovered an edge. They may have discovered a coincidence.

Overfitting often produces strategies that are fragile. A small change in market, timeframe, spread, slippage, or volatility can damage performance.

The backtest looks clean.

Live trading feels completely different.


Optimising vs Overfitting: The Key Difference

The simplest way to separate the two is this:

Optimisation improves a strategy’s logic. Overfitting improves a strategy’s past results.

Optimisation is about building something more robust.

Overfitting is about making the historical chart look better.

Here is the practical difference:

FeatureOptimisationOverfitting
Main goalImprove strategy qualityImprove historical results
Based onMarket logic and reviewTrial and error until results look best
RulesSimple and explainableHighly specific and fragile
ResultMore robust processBetter-looking backtest
RiskStill needs testingOften fails in live markets
Question asked“Does this rule make sense?”“Does this improve the numbers?”

A properly optimised strategy should still be understandable.

You should be able to explain why each rule exists.

An overfitted strategy often sounds complicated because the rules were added to avoid past losses rather than improve future decision-making.

For example:

“Only trade breakouts when the 34 EMA is above the 89 EMA, RSI is between 52 and 61, ATR is above last week’s average, and the setup happens between 9:15 and 10:40 on Tuesdays and Thursdays.”

Could that rule work? Maybe.

But if those filters were added only because they improved one backtest, the strategy may be too fitted to historical noise.

Complexity is not the same as quality.


Why Overfitting Is So Tempting

Overfitting is tempting because it feels productive.

You are testing. You are analysing. You are improving the numbers. It feels professional.

The problem is that the trader can slowly move from research into curve-fitting without noticing.

Every small adjustment seems reasonable:

  • Move the stop a little wider.
  • Change the target slightly.
  • Add one more filter.
  • Avoid one specific time of day.
  • Remove a losing period.
  • Change the moving average length.
  • Exclude a market that performed poorly.

Individually, each change may seem harmless.

Together, they can create a strategy that is built around the past rather than prepared for the future.

There is also an emotional reason.

Traders want certainty.

A smooth backtest gives comfort. It reduces doubt. It makes the trader feel as if they have found something reliable.

But the market does not reward comfort.

It rewards strategies that can handle uncertainty, imperfection, and changing conditions.

A perfect-looking backtest should not automatically excite you.

Sometimes it should make you suspicious.


Common Signs Your Strategy May Be Overfitted

Overfitting is not always obvious, but there are warning signs.

1. Tiny Rule Changes Destroy Performance

If changing one setting slightly causes results to collapse, the strategy may be fragile.

For example, if a strategy works with a 37-period moving average but fails with 35 or 40, that is a concern.

A robust strategy should usually perform reasonably across a range of similar settings.

It does not need to be perfect everywhere, but it should not depend on one magical number.

2. Too Many Filters

Filters can be useful, but too many can be a warning sign.

If every losing trade in the past has been removed by adding another rule, the strategy may be avoiding history rather than solving a real problem.

A good filter should have a reason.

For example, avoiding low-liquidity periods may be logical. Avoiding one random hour because it removed three losing trades may not be.

3. The Backtest Looks Too Smooth

Real trading is messy.

A backtest with very few drawdowns, almost no losing streaks, and unusually perfect results should be reviewed carefully.

Strong strategies can perform well, but no strategy avoids uncertainty completely.

If the equity curve looks too clean, ask whether the rules were adjusted too heavily.

4. The Strategy Only Works on One Market

A strategy does not need to work on every market, but if it only works on one instrument during one specific period, be careful.

It may be capturing a temporary pattern rather than a durable behaviour.

Testing similar markets can help. For example, if a strategy works on one major forex pair, does it behave reasonably on others? If it works on one index, does it show similar logic on another?

5. You Cannot Explain Why the Rules Exist

This is one of the biggest warning signs.

If your only explanation is:

“Because it improved the backtest,”

that may not be enough.

A strong rule should have a market-based reason.

It should help with structure, risk, timing, volatility, liquidity, or behaviour.


How Backtesting Can Fool You

Backtesting can create false confidence in several ways.

Hindsight Bias

When looking at historical charts, it is easy to see what happened next.

This can make setups look clearer than they felt at the time.

You may think you would have entered perfectly, held calmly, and exited correctly. In live trading, the same chart unfolds one candle at a time, with uncertainty attached to every decision.

Cherry-Picking

Cherry-picking happens when traders focus on examples that support the strategy and ignore examples that do not.

They remember the clean winners and forget the messy losers.

A fair backtest must include every valid setup, not just the attractive ones.

Ignoring Costs

Spreads, commissions, slippage, and execution delays matter.

A strategy that looks profitable before costs may be weak after costs.

This is especially important for short-term strategies where the average profit per trade may be small.

Small Sample Size

A strategy tested on 10 trades tells you very little.

A few winners can make weak rules look strong. A few losers can make useful rules look poor.

A larger sample gives a better picture, though even then it is not perfect.

Changing the Rules Mid-Test

This is extremely common.

A trader starts testing one strategy, sees a problem, changes the rules, then continues counting the results as if it was the same test.

That creates misleading data.

If the rules change, the test should usually restart or be clearly separated.


How to Optimise Properly

Optimisation is not the enemy.

Poor optimisation is.

A practical optimisation process should be structured and controlled.

1. Start With Clear Rules

Before testing anything, write the strategy down.

Include:

  • Market.
  • Timeframe.
  • Setup.
  • Entry rule.
  • Stop-loss rule.
  • Target rule.
  • Risk rule.
  • Market condition filter.
  • Trade management rules.

If the rules are unclear, the test will be unreliable.

For more on this foundation, read: Building a Repeatable Trading Strategy From Scratch.

2. Test the Base Version First

Do not optimise immediately.

First, test the simplest version of the strategy.

This gives you a baseline.

You need to know how the original idea performs before deciding what to improve.

3. Change One Variable at a Time

If you change the stop, target, entry, timeframe, and filter all at once, you will not know what made the difference.

Change one thing. Test it. Record the result.

Then decide whether the change is worth keeping.

4. Use Market Logic

Do not add rules just because they improve the numbers.

Ask why the rule should work.

For example:

  • A volatility filter may help a breakout strategy because breakouts need movement.
  • A trend filter may help a pullback strategy because pullbacks work best within structure.
  • A time filter may help an intraday strategy if liquidity is consistently better during certain sessions.

The rule should make sense beyond the backtest.

5. Accept Imperfection

A strategy with some losses is normal.

Do not try to remove every losing trade.

Losses are part of trading. A strategy that tries to avoid every past loss often becomes too restrictive or fragile.

Your goal is not a perfect backtest.

Your goal is a strategy that is clear, realistic, and repeatable.


A Simple Robustness Check

A useful question to ask is:

Does the strategy still make sense if conditions are slightly different?

For example:

  • Does it still perform reasonably with a slightly wider or tighter stop?
  • Does it still make sense on a similar market?
  • Does it survive different volatility conditions?
  • Does it work across more than one historical period?
  • Does it remain logical after costs?
  • Does it still produce trades without needing highly specific filters?

This does not guarantee future performance.

Nothing does.

But it can help you avoid strategies that only worked because they were fitted to one perfect historical sample.

A robust strategy should not be dependent on perfect conditions.

It should have room for real-world messiness.

That includes missed entries, slippage, emotional pressure, changing volatility, and imperfect execution.


The Role of Forward Testing

Backtesting looks backwards.

Forward testing looks ahead.

Forward testing means applying your strategy in real time, either on a demo account, paper trading journal, or very small live position size.

This matters because forward testing introduces uncertainty.

You no longer know what the next candle will do. You must follow the rules as the market unfolds.

Forward testing helps reveal:

  • Whether you can actually execute the strategy.
  • Whether signals are clear in real time.
  • Whether the strategy creates emotional pressure.
  • Whether trade frequency is realistic.
  • Whether spreads and execution affect performance.
  • Whether your backtest assumptions were too optimistic.

A strategy that looks good in backtesting but feels impossible to follow in real time may not be suitable for you.

This is especially important for part-time traders.

A five-minute strategy may backtest well, but if you are working during market hours, you may miss entries, manage trades poorly, or make rushed decisions.

Your strategy must fit your life, not just your spreadsheet.


Backtesting and Psychology

Backtesting is technical, but it is also psychological.

Traders often use backtesting to search for certainty.

They want the numbers to remove fear.

But no amount of testing removes uncertainty completely.

Even a well-tested strategy can lose. Even a strong edge can go through drawdown. Even a good process can feel uncomfortable in live conditions.

This is where many traders struggle.

They build a strategy, test it, feel confident, then panic when the first few live trades lose.

The issue is not always the strategy. It may be that the trader expected the backtest to protect them emotionally.

It cannot.

A backtest can prepare you, but it cannot trade for you.

You still need discipline, patience, and risk control.

This is why next week’s post matters. Once the strategy is built and tested, the trader still has to execute it under pressure.

That is where emotions begin to distort decision-making.


Practical Backtesting Checklist

Before trusting a backtest, ask:

  1. Are the rules written clearly?
  2. Did I include every valid setup?
  3. Did I avoid changing rules during the test?
  4. Is the sample size large enough to be useful?
  5. Did I include spreads, commissions, and slippage where relevant?
  6. Does each rule have a logical reason?
  7. Have I tested more than one market condition?
  8. Does performance survive small changes to settings?
  9. Is the strategy realistic for my schedule?
  10. Have I forward tested it before increasing risk?

This checklist will not make your strategy perfect.

But it will reduce the chance of fooling yourself.

The goal is not to prove that your idea works.

The goal is to test whether it deserves more attention.

That mindset is important.

A trader who backtests to prove themselves right will often find what they want to see.

A trader who backtests to find weaknesses will usually build a stronger process.


Common Mistakes to Avoid

Mistake 1: Searching for the Perfect Settings

There is no perfect moving average, RSI setting, stop size, or target distance.

Settings should support the logic of the strategy. They should not become the strategy.

Mistake 2: Removing Every Losing Trade

Losing trades are normal.

If your optimisation process removes every loss from the past, it may also remove the strategy’s ability to function in the future.

Mistake 3: Testing Only One Market Phase

A strategy tested only during a strong trend may look excellent, but fail when the market becomes choppy.

Test across different conditions where possible.

Mistake 4: Ignoring Execution Costs

Costs matter.

This is especially true for short-term trading, where small differences can turn a profitable backtest into an unprofitable live strategy.

Mistake 5: Trusting the Backtest Too Quickly

A backtest is a research tool, not a guarantee.

It should lead to further testing, journaling, and careful live execution with controlled risk.


Final Thoughts: The Best Backtest Is Honest, Not Perfect

Backtesting is valuable.

But only if it is honest.

A perfect-looking backtest can be dangerous if it was created by over-adjusting rules, removing uncomfortable losses, and fitting the strategy too closely to the past.

Good optimisation improves a strategy’s logic.

Overfitting improves its appearance.

That difference can decide whether a strategy has a realistic chance in live markets or collapses when conditions change.

As a trader, your job is not to create the most impressive historical result.

Your job is to build a process that is clear, testable, realistic, and robust enough to handle uncertainty.

That means accepting losses. It means testing properly. It means keeping rules explainable. It means resisting the temptation to keep adjusting until the past looks perfect.

The market will never give you certainty.

A good backtest should not pretend otherwise.

It should help you understand your strategy, respect its limits, and prepare for the emotional challenge of executing it in real time.

Because once the testing is done, the real test begins.


What Comes Next

Even the best backtest cannot remove emotion from trading.

A trader can have a clear strategy, sensible risk management, and realistic expectations — then still make poor decisions when money is on the line.

Fear can make you exit too early. Greed can make you oversize. Frustration can make you revenge trade. Confidence can turn into carelessness.

That is why the next guide moves from testing to behaviour.

Next post: The Psychology of Risk: How Emotions Distort Decision-Making


Related Trading Reads


Post Navigation

Previous: Why Most Trading Strategies Fail Over Time
Next: The Psychology of Risk: How Emotions Distort Decision-Making


FAQ

What is the difference between optimising and overfitting?

Optimising means improving a trading strategy in a logical and controlled way. Overfitting means adjusting a strategy too closely to past data so that it looks good historically but struggles in live markets.

Is backtesting reliable?

Backtesting is useful, but it is not a guarantee. It can help you understand how a strategy might have performed in the past, but live markets include uncertainty, execution costs, slippage, changing conditions, and emotional pressure.

How do I know if my strategy is overfitted?

Warning signs include too many filters, settings that only work on one exact number, performance that collapses after small rule changes, a backtest that looks too smooth, or rules that have no clear market logic.

Should I optimise my trading strategy?

Yes, but carefully. Optimisation can improve a strategy when changes are based on market logic and tested properly. The danger comes from adjusting rules only to make historical results look better.

Why do perfect backtests often fail?

Perfect-looking backtests often fail because they may be fitted too closely to past price behaviour. Live markets are uncertain, and a strategy that was built around historical noise may not adapt well to new conditions.


Call to Action

Do not use backtesting to prove that your idea is perfect.

Use it to find weaknesses.

Write the rules clearly. Test the base version first. Change one variable at a time. Include realistic costs. Accept normal losses. Then forward test before increasing risk.

A strong trader is not looking for the prettiest backtest.

They are looking for a strategy they can understand, execute, review, and improve.

For more structured trading education, continue with the next Stocked & Shared guide: The Psychology of Risk: How Emotions Distort Decision-Making.


Discover more from Stocked And Shared

Subscribe to get the latest posts sent to your email.

Leave a Reply

Discover more from Stocked And Shared

Subscribe now to keep reading and get access to the full archive.

Continue reading