← Back to the blog

2026-11-02 · Ethan Miller

How to Backtest a Trading Strategy Without Fooling Yourself

Share

To backtest a trading strategy, write its rules precisely enough that a computer could follow them, run them over historical data with realistic costs, and judge the result on data you did not use to design the rules. That last step is the one most backtests skip, and it is why so many strategies that look great on paper lose money live.

Below is the process step by step, the numbers to judge a result by, and a real example: a US30 strategy we coded and tested, which lost, and what happened when we tried to fix it honestly.

Key takeaways

  • Rules first. If a rule needs judgement ("a strong trend", "a clean pullback"), it cannot be tested yet.
  • Costs in from the start. On a small edge, the spread alone can be the difference between profit and loss.
  • Split the data before you begin. Design on one part, test once on a part you never looked at.
  • Measure in R (multiples of the amount risked), not dollars, and always alongside the number of trades.
  • Small samples lie. A few dozen trades cannot tell a small edge from luck.

Step 1: Write rules a computer could follow

"Buy the pullback to the point of control in an uptrend" sounds like a rule, but it is not testable until every word is defined. Which day's volume profile? What counts as an uptrend, measured how and when? Where exactly is the entry, the stop, the target? What happens to a trade still open at the end of the day?

When we tested this idea, we had to pin each one down. We used yesterday's volume profile, called it an uptrend when the first 1-hour candle after the 9:30 New York open opened above yesterday's value area high, entered with a limit order at yesterday's point of control, put the stop 5 points beyond the opposite edge of the value area, and allowed one trade a day.

If you cannot write your strategy that precisely, the backtest will quietly fill the gaps with hindsight, and the result will measure your hindsight, not the strategy.

Step 2: Put the costs in before you look

Every real trade pays a spread, and often commission and slippage. Add them to every trade in the test, at a realistic level for your broker. We charged 2 points on every US30 trade.

This matters more than it sounds. A strategy that makes a few hundredths of an R per trade can be wiped out by a slightly wider spread, and a backtest without costs will never show you that.

Step 3: Split the data before you start

If you tweak rules on the same data you judge them on, something will eventually look profitable by luck. The fix is to split the data before the first run:

  • In-sample data is where you design and adjust the rules.
  • Out-of-sample data is kept unseen and used once, for one final test of the locked rules.

We used 2025 to design and 2026 as the unseen test. A result on data used for tuning partly measures the tuning; only unseen data can say whether the rules generalise.

Step 4: Write the ground rules for changes

Decide how you will change the strategy before any run, not after you see a disappointing result. Ours were:

  • Change one thing at a time, each for a stated reason.
  • Keep a change only if average R per trade improves.
  • Ignore any run with too few trades to mean anything.

These rules make it possible to fail, which is exactly what makes a pass worth something.

Step 5: Measure the right numbers

Judge a backtest in R, so a result does not depend on account size or position size. These are the numbers that matter:

MetricWhat it tells you
Number of tradesWhether any other number can be trusted
Win rateHow often it wins, meaningless on its own
Average win and average loss (R)How big winners and losers are
Breakeven win rateAverage loss ÷ (average win + average loss): the win rate it needs just to break even
Expectancy (R per trade)(Win rate × average win) − (loss rate × average loss): the edge per trade
Profit factorGross profit ÷ gross loss: above 1 makes money, below 1 loses it
Maximum drawdown (R)The worst peak-to-trough run you would have had to sit through

A real example: the strategy that lost

We coded the volume profile rules above and ran them on US30 (a CFD, 1-hour chart) from January 2025 to September 2026.

The result: 71 trades, 36.6% winners, a profit factor of 0.66 and −14.2R in total. The average win was +1.05R and the average loss −0.92R, so it needed a win rate of about 46.7% to break even. It won 36.6% of the time, about ten points short.

The fills were the wrong days

The deeper problem was not visible in the headline numbers. The rules placed 285 orders, and only 71 filled. On 237 of the 247 days when price ran all the way to yesterday's high or low, there was no trade: price never came back to the point of control to fill the order.

So the trades that did fill were mostly on days when price came all the way back, which are the days the move was failing. Waiting for a deep pullback selected the worst trades. A selection effect like this is invisible unless you count the orders that did not fill as well as the ones that did.

What we changed, using 2025 only

VersionAverage per tradeTrades
Original rules−0.17R44
Fixed 2R target−0.16Rnot counted: bigger winners, fewer of them
Enter on a retest of the value area edge, stop beyond the point of control−0.05R76
Add a confirmation candle (touch the edge, close back beyond it)−0.02R58
Only trade the first three hours−0.06Rdropped: it made things worse

The confirmation version was locked. On 2025 it was still break-even at best.

The one unseen test

The locked rules, run once on January to September 2026: 47 trades, 44.7% winners, average win +0.91R, average loss −0.57R, +4.2R in total, profit factor 1.28, worst drawdown 6.1R. Across all 21 months the same rules made +3.0R over 105 trades, about +0.03R per trade.

That is promising, and it is not proof. With under fifty trades, a result this size is well within normal variance. It passed a test it could have failed, which is worth something, but it needs many more trades, ideally from live forward testing, before anyone should trust it with size. There are practical limits too: 31 of the 47 trades hit neither stop nor target and were closed at the end of the day, and a spread much wider than 2 points erases most of the edge.

The full study, with every rule, is in our free lesson We Backtested It: The VP Strategy.

How many trades is enough?

There is no magic number, but the arithmetic is unforgiving. If each trade's result swings by about 1R either way and the true edge is +0.1R per trade, it takes roughly 400 trades before the average sits two standard errors above zero. A smaller edge needs more; a larger one needs fewer.

The practical rule: the smaller the edge, the more trades you need before you believe it, and a few dozen trades can only rule out disasters, not confirm an edge.

Six ways backtests lie

MistakeWhat it looks likeThe fix
Curve fittingSettings tuned until the equity curve is smoothDesign on in-sample data, test once on unseen data
Look-ahead biasUsing a candle's high, low or close before that candle has finishedOnly use information available at the moment of the decision
Ignoring costsA small edge that only exists before spread and slippageCharge a realistic cost on every trade
Optimistic fillsCounting a limit order as filled the moment price touches itRequire price to trade through the level, or accept fewer fills
Small samplesA great result from 20 or 30 tradesReport the trade count next to every number
Moving the goalpostsChanging the test after seeing the resultWrite the ground rules before the first run

Manual or coded?

Both work if the rules come first. A coded backtest (in MetaTrader 5's Strategy Tester, Python or similar) is faster and cannot cheat, as long as the code matches the rules. A manual backtest with a chart's bar replay is slower but fine, as long as you write the rules down first, log every trade the rules give you (including the ones you would rather skip), and never look ahead of the current candle.

After the backtest: forward test it

A backtest tells you how rules would have done. A forward test tells you whether you can actually follow them in real time, with real spreads and real nerves. Run the locked rules on a demo or on the free live US30 simulator, which uses a $100,000 account with prop-firm rules. Log each trade in a trading journal so you can compare the live numbers with the backtest.

If the live results look like the backtest after enough trades, you have something. If they do not, you have learned it for free.

backtestingstrategy testingtrading statistics

Frequently asked questions

How many trades do you need for a backtest to be meaningful?

More than most people use. If each trade swings by about 1R and the true edge is +0.1R per trade, it takes roughly 400 trades before the average is two standard errors above zero. A few dozen trades can rule out a disaster, but they cannot confirm a small edge.

What is out-of-sample testing?

Testing a strategy's locked rules on data that was never used to design or adjust them. You split your history before you start: design on the in-sample part, then run one final test on the out-of-sample part. Only that unseen result says whether the rules generalise.

What is curve fitting in trading?

Adjusting a strategy's settings until it looks good on the data you are testing it on. Because the settings were chosen to fit that data, the result says little about the future. The fix is out-of-sample testing: tune on one part of the data and judge on another you never looked at.

Is a profit factor of 1.28 good?

It means the strategy made $1.28 for every $1 it lost, which is profitable, but whether it is good depends on the trade count and costs. In our US30 test, a profit factor of 1.28 came from 47 trades, which is too few to separate a real edge from luck.

Can I backtest a strategy manually?

Yes. Write the rules down first, replay the chart one candle at a time, log every trade the rules produce (including the ones you would rather skip), and never look ahead. It is slower than a coded test but just as valid if you follow those rules.

Comments