To backtest a trading strategy, you apply fixed written rules to past price data, record every trade the rules would have taken, and judge the results after costs. Done honestly, it tells you whether an idea deserves more of your time. Done carelessly, it mostly measures how good your hindsight is.
Quick answer: how do you backtest a trading strategy?
1) Write entry, stop, exit and filter rules precisely, 2) choose a market, timeframe and test period that includes different conditions, 3) step through the chart candle by candle and log every valid trade with spread included, 4) review expectancy and drawdown, 5) confirm on fresh data and forward test before risking money.
What backtesting can and cannot tell you
A backtest answers one narrow question: if these exact rules had been followed on this data, what would have happened? It can show that an idea has no edge, that its losing streaks are longer than you could stomach, or that costs swallow the profit.
It cannot prove the strategy will work in future. Markets change, and a test is only as good as the rules and data you feed it. We treat a good backtest as permission to keep testing, not permission to trade large.

Step 1: write rules a stranger could follow
Most backtests fail before the first trade, because the rules are vague. “Buy at strong support when price looks bullish” cannot be tested; two people would take different trades. If you are still shaping the method, start with our guide on how to develop your own trading system.
- Filters: which conditions must be true before you look for a trade, such as trend direction on a higher timeframe.
- Trigger: the exact candle or event that gets you in. Our filters and triggers entry checklist shows one way to split the two.
- Stop: where it goes and why, defined by price, not by feel.
- Exit: a fixed target, a trailing rule or a time limit.
- Size: a fixed risk per trade, so results can be read in R (multiples of the amount risked).
Discretionary price action can still be tested, but you must write down what you mean by each judgement call. Our comparison of systems trading vs discretionary trading covers where that line sits.

Step 2: choose the data and the sample
Pick one market and one timeframe to start. Test a period long enough to include trends, ranges and at least one volatile spell, because a strategy that only met one kind of market has not really been tested.
There is no agreed minimum number of trades. Thirty trades can be badly skewed by a few outliers, so we aim for at least 100 before drawing any conclusion, and more for strategies that trade rarely. Before you start, set aside the most recent slice of data and do not look at it; you will need it later.

Step 3: run the test candle by candle
- Hide the future. Use your platform’s bar replay or scroll so the right-hand side of the chart is covered. If you can see what happened next, you will find reasons to skip the losers.
- Move forward one candle at a time. Check the filters, then the trigger, exactly as written.
- Log every valid signal. Record the date, entry, stop, target, result in R and any notes, including trades you would rather not have taken.
- Include costs. Add the typical spread to every entry and exit, and a little extra around news. Our guide to the bid-ask spread as a trading cost shows how to work it out.
- Do not change the rules mid-test. Write ideas in a separate list and test them later as a new version.
A spreadsheet is enough. The fields overlap heavily with a live log, so the template in our trading journal for beginners works well here too.

Step 4: read the results properly
Win rate on its own tells you very little. A strategy that wins 35% of the time can be sound if winners are much larger than losers, as we explain in why win percentages matter less than risk:reward.
| Measure | What it tells you | Warning sign |
|---|---|---|
| Expectancy (average R per trade) | Whether the rules made money after costs | Positive only before costs |
| Maximum drawdown | The deepest fall from a peak | Deeper than you could sit through |
| Longest losing streak | How it will feel live | A streak that would make you quit |
| Results by period | Whether the edge is spread out | All profit from one month |
| Number of trades | How much the figures can be trusted | Too few to mean much |
Losing streaks deserve special attention. Our sibling guides on risk of ruin in trading and handling a trading drawdown show why a run of losses that looks small in a spreadsheet can be large in practice.
Worked example: one rule set, tested honestly
Example, using hypothetical figures. A trader tests a breakout rule on one currency pair over 120 trades, risking a notional £50 (1R) per trade on a £5,000 test account.
- Before costs: 48 winners averaging +2R and 72 losers at −1R gives +24R, or £1,200.
- After a typical spread: costs of 0.1R per trade take off 12R, leaving +12R, or £600.
- On the hidden data: 40 fresh trades come out at roughly breakeven.
The honest conclusion is not “it works”. It is that the edge is thin, sensitive to costs and unconfirmed out of sample. That trader should refine the idea or move on, not raise their size.

Common mistakes when you backtest a trading strategy
- Hindsight entries. Seeing the move first, then “finding” the setup.
- Overfitting. Tuning settings until the past looks perfect. Test enough variations and one will look good by chance; Harvey, Liu and Zhu argued that, because so many ideas have been tested, a new finding needs to clear a much higher statistical bar. The same applies to your own spreadsheet.
- Ignoring costs. Spread and slippage turn many short-term edges negative.
- Testing one market mood. A trend-only sample flatters trend strategies.
- Skipping the forward test. Real-time decisions feel different from scrolling a chart.
From backtest to forward test to live
After a backtest, run the same rules forward in real time on a demo account for several weeks, logging every trade. If the results stay roughly in line, move to live trading at a small size; our guide on when to move from demo to live trading covers that step. Leveraged products such as CFDs and spread bets can lose money quickly, so keep risk per trade small while the strategy proves itself.
Frequently asked questions
How many trades do I need in a backtest?
There is no fixed number, and forum advice varies widely. We want at least 100 trades across different market conditions, and more for strategies that trade rarely or have a low win rate.
What is the difference between backtesting and forward testing?
Backtesting applies your rules to past data. Forward testing applies them in real time, on demo or very small size, so you face the same uncertainty and timing as live trading.
Can I backtest price action without code?
Yes. Manual backtesting with bar replay and a spreadsheet works well for price action, provided every judgement call is written down before you start.
Does a good backtest mean the strategy will work?
No. It means the rules worked on that data. Confirm on unseen data and in a forward test, and expect live results to be somewhat worse.
Next steps
Once a strategy survives testing, write it into your plan. Our guide on how to create a trading plan with a fill-in template shows where the rules, risk and review routine go.
The filters and trigger process and a rules-based risk model are both covered in our price action trading course, and the basics section is free to start.
This article is for education only and is not financial advice. Trading leveraged products such as CFDs and spread bets carries a high risk of losing money.




