How to backtest a trading strategy without fooling yourself

8 min read · Updated November 10, 2026

In short
  • A backtest runs your exact rules over past prices to show what they would have done. It's the cheapest way to reject a bad idea.
  • It's also easy to fool yourself: optimistic fills, missing fees, and tuning settings until the past looks perfect (overfitting).
  • The honest version: realistic fills and fees, enough trades, a test period you didn't tune on, and then forward testing on new sessions.
  • A good backtest is evidence, not a promise. Markets change.

Once a strategy is written as exact rules (see turning an idea into rules), you can ask a computer what those rules would have done over the last few months. That's a backtest. Done well, it saves you from trading an idea that never worked. Done badly, it gives you false confidence in an idea that only worked on paper.

What a backtest does

The tester walks through historical price bars one at a time, in order. On each bar it runs your rules exactly as live trading would: is there an entry signal? Did the price reach the stop or the target? Is it time to be flat? It records every trade with its entry, exit, fees and result, then summarises: number of trades, win rate, average win and loss, net result, and the worst run of losses (the drawdown).

The key rule: a backtest may only use information that was available at the time. If your rule uses a bar's close, the earliest you could act is after that bar closed, so the fill comes at the next price, not the close itself.

Five ways backtests lie

1. Fills that are too good

Assuming you got the exact close, or your limit price the moment it was touched, flatters every result. Realistic testers fill a signal at the next bar's open and add slippage, a tick or two of worse price on market and stop orders.

2. Ignoring fees

Commissions and exchange fees are charged on every round trip. A strategy that makes a little on each of hundreds of trades can lose money once fees are in. Put them in from the first test.

3. Not knowing what happened inside a bar

A 5-minute bar shows its open, high, low and close, not the order they happened in. If one bar touches both your stop and your target, the tester has to guess. The cautious guess is that the stop came first.

4. Too few trades

Ten trades tell you almost nothing; a lucky week can look like an edge. You want dozens at the least, across different kinds of days: trending, choppy, quiet, news-heavy.

5. Overfitting

This is the big one. Try enough settings (a 9 and 21 average, then 8 and 20, then 10 and 23) and one will look great on the past by chance. It has learned the noise of those particular months, not a pattern that repeats. The tell: the result is excellent at one exact setting and poor at the settings next to it.

How to test honestly

Backtesting in TradeHarbor

In the builder. The Strategy lab's Test it backtests your blocks as they stand and splits the results into earlier and later sessions, so overfitting shows up as a strategy that only works in the first half. Try a range tests several values of one setting at once. A value that only does well in the earlier sessions is probably fitted to them.

In the Backtester (Pro). Pick a template (opening range breakout, moving average cross, RSI mean reversion) or your own saved strategy, and set the starting capital, order size, commission and slippage. It uses price history from your own broker connection (index futures from ProjectX, as far back as it serves your account; coin pairs and US stocks from Alpaca), fills signals at the next bar's open, and counts the stop first when a bar touches both. You get a performance summary for longs and shorts, every trade, a stress test, an out-of-sample check, a time-of-day heat map, and a replay of the run under a prop firm plan's drawdown, daily limit and profit target. A broker serves a year or so at most, so the Backtester is a first check, not the last one.

Forward testing. Save and forward test keeps running the same strategy, unchanged, on each new session, so you build up results on data the strategy has never seen.

Against the rules you'll trade under. Results feed the pass simulator, which replays the strategy's days against every firm's evaluation rules. A strategy can be profitable and still fail an evaluation, because of its drawdown or one oversized day.

What a good backtest does and doesn't tell you

A careful backtest that holds up on unseen data and in forward testing is real evidence that your rules had an edge in those conditions. It isn't a promise about next month. Markets change, and a strategy can stop working. That's why live results should keep being compared with the backtest. When they drift apart, you'll know early.

Next steps

A tested strategy is ready to run on live prices, ideally watched in shadow mode before it trades. How trading APIs work explains how a program talks to your broker, and how automated trading works follows one trade from signal to fill.

Build it, test it, then automate it

Describe your idea in TradeHarbor's Strategy lab and see the rules and the Python they become. Test it on real futures history on Pro, then let it trade for you with automation.

Start free

Educational content only. Nothing here is investment, financial, or trading advice, and TradeHarbor is not affiliated with any prop firm or broker mentioned. Trading futures involves substantial risk of loss. Each firm's current published rules always govern.