Trading plan · Advanced

Trading Plan Backtesting Basics

Applying written rules to old data, mechanically, including every instance you would rather not count.

Last reviewed by the MarketPro research desk · Editorial policy

In short

Backtesting applies a trading plan's written entry, exit and sizing rules to historical price data, in order, recording every trade the rules produce rather than the memorable ones. It gives you a win rate, an average win and loss, and an expectancy figure. To be worth anything it needs precise rules, realistic spread and slippage charged on every trade, and a sample large enough to span trending, ranging and volatile conditions.

What to remember

  • Charging 1.5 pips of spread and slippage removed 30% of a 600 pip three-year result, and it removes three quarters of the edge on a 55% win rate at 1:1.
  • On 30 trades the 95% band around a 38% win rate runs from about 21% to 55%, so a small sample cannot tell a working rule from a losing one.
  • Nine ambiguous bars out of 120 moved the measured expectancy from 5.0 pips to 9.5 purely through how the stop-or-target-first question was resolved.
  • Testing 40 parameter combinations on one period selects the luckiest variant, which is why a held-back twelve months is worth more than a better optimiser.
  • A favourable backtest is evidence about past price behaviour, not a forecast of future performance.

Backtesting is your own rules replayed on old data, in order

Backtesting means taking the entry, exit and sizing rules you have written down, applying them to historical price data bar by bar in the order the bars arrived, and recording every trade the rules produce. Not the good ones. Every one. The output is a list of trades with dates, entry prices, exit prices and outcomes, and from that list you get a win rate, an average win, an average loss and an expectancy figure. That is the whole exercise. It gathers evidence without risking capital, and it tells you nothing you did not put into the rules.

It fails before it starts if the rules are too vague to apply mechanically. "Buy the pullback in an uptrend" cannot be backtested, because two people reading it will mark up different trades, and so will you on two different days. "Buy at the close of the first candle that closes back above the 20 EMA, after price has held above the 200 EMA for at least ten bars" can be. Tightening a loose plan until it is testable is most of the value here, and it happens before you look at a single result.

One hundred and twenty EUR/USD trades, before and after costs

Here is a small breakout rule run across three years of EUR/USD four-hour data. It produced 120 trades. The right-hand column charges every trade 1.5 pips, being a 1.2 pip spread plus 0.3 pips of average slippage.

MeasureGrossAfter 1.5 pips of cost
Trades120120
Winners46 (38.3%)46 (38.3%)
Average win42.0 pips40.5 pips
Average loss18.0 pips19.5 pips
Expectancy per trade+5.0 pips+3.5 pips
Three-year total+600 pips+420 pips

Costs removed 30% of the result, and 1.5 pips is a mild assumption on EUR/USD in London hours and an optimistic one on anything thinner or anything traded across the daily rollover. A backtest run gross is not an optimistic version of the same strategy, it is a different strategy that nobody can trade. Convert the pip figures into money for your own lot size with the pip calculator before deciding whether 3.5 pips a trade is worth the screen time.

Notice also what carries this record. A 38.3% win rate is fine because the average win is 2.3 times the average loss. Apply the same 1.5 pips of cost to a 55% win rate at 1:1 on a 20 pip target and the gross edge of 2.0 pips a trade falls to 0.5, which is inside the noise. The cost line matters most to the strategies that trade most often.

How many trades before the win rate means anything

A win rate measured on a small sample is a wide range pretending to be a number. At a true rate near 38%, the 95% band on 30 trades runs from about 21% to 55%. Two hundred trades narrows it to roughly 31% to 45%. Five hundred gets you to about 34% to 43%.

Read that first band again. On 30 trades you cannot distinguish a strategy that loses steadily from one that works, which is why a backtest of a handful of favourable examples is not weak evidence but no evidence. It also means the sample has to span varied conditions, not one clean trending stretch. Three years of EUR/USD contains trending months, ranging months, a rate-cycle turn and at least one volatility shock, and a rule that only earns its expectancy in one of those has an exposure problem the plan needs to name.

10 more sections in MarketPro

Finish this lesson in MarketPro

The rest of Trading Plan Backtesting Basics, a quiz that checks it landed, and your place kept in the curriculum.

  • 10 more sections of this lesson
  • All 320 lessons, with no cap and no paywall
  • Free on any account, including a free one
In your browserContinue on webor continue on web

Same account as the app · No install · Free to start

Or scan with your phone camera to get the MarketPro app.

Not investment advice. Past performance is not indicative of future results.

Run the numbers while this is fresh

Work it through on your own position size. Nothing leaves your browser and there is no sign-up: Position size calculator, Risk of ruin calculator, Compounding calculator.

Written and reviewed by the MarketPro research desk

MarketPro is a trading-signal and trading-education app operated by Harajuku Holdings LTD (Cyprus). Our signal desk publishes and tracks every trade idea in-app, and every page here is checked against the app's live behaviour before publishing. Last reviewed . How we produce signals and content · About MarketPro

FAQ

Trading Plan Backtesting Basics: questions

How many trades does a backtest need to be meaningful?
More than most people run. At a true win rate near 38%, a 30-trade sample carries a 95% confidence band of roughly 21% to 55%, which is too wide to act on. Two hundred trades narrows it to about 31% to 45% and five hundred to about 34% to 43%. Sample breadth matters as much as sample size, so the trades should span trending, ranging, high-volatility and quiet periods rather than one favourable stretch.
What is overfitting in backtesting?
Overfitting is tuning rules until they describe the historical sample rather than the market, so the result does not hold up going forward. It happens most often through parameter search: test 40 combinations on the same three years and the best of the 40 will look good even if all 40 are noise, because you selected on the noise. The usual defences are fewer parameters, a held-back out-of-sample period, and checking that the out-of-sample expectancy lands within roughly 40% of the in-sample figure.
Should I include spreads and slippage in a backtest?
Yes, charged on every trade, because leaving them out measures a strategy nobody can trade. In a 120-trade EUR/USD example, 1.5 pips of cost per trade cut a 600 pip gross result to 420 pips, a 30% reduction. The effect scales with trade frequency, so a scalping rule can have its entire gross edge removed by costs while a swing rule barely notices. Use the spread your own broker actually shows at the hours you trade, not the headline figure.
Trade · Learn · Earn

The whole academy is free in MarketPro

All 320 lessons, 12 guided paths, quizzes and a daily streak. Free on every account, in the app or your browser, with vetted free signals alongside it.

Same account as the app · No install · Free to start

Not investment advice. Past performance is not indicative of future results.