Most beginners test a new strategy with real money. They place 10 trades, lose 6, and decide the strategy “doesn’t work.” Ten trades tell you almost nothing.
Backtesting fixes this. You apply your rules to past price data and see how they would have performed over hundreds of trades. This guide shows you how to backtest a trading strategy in 7 steps, which numbers to read, and how to move from backtest to demo to live trading.
What Is Backtesting?
Backtesting means running a trading strategy on historical data to measure its results. You record every trade the rules would have taken: entry, stop loss, take profit, and outcome. At the end, you have a sample large enough to judge the strategy with numbers instead of feelings.
A backtest answers three questions:
- Does the strategy make money over a large sample?
- How deep are the losing periods?
- Can you follow the rules without guessing?
Manual vs Automated Backtesting
| Manual backtesting | Automated backtesting | |
|---|---|---|
| How it works | You scroll through past charts and log trades by hand | Software runs coded rules on historical data |
| Tools | TradingView Bar Replay, MT5 visual mode, a spreadsheet | MT5 Strategy Tester with an Expert Advisor, Python |
| Speed | Slow, around 100 trades in a few evenings | Thousands of trades in minutes |
| Best for | Discretionary traders, price action, SMC | Rule-based systems you can code |
| Main risk | Hindsight bias | Overfitting |
If you trade with price action or Smart Money Concepts, start with manual testing. If your rules use indicators with fixed values, an automated test on MetaTrader 5 is faster.
How to Backtest a Trading Strategy in 7 Steps
Step 1: Write rules with zero grey areas
Write your strategy so a stranger could follow it. Vague rules like “buy when the trend looks strong” cannot be tested. Clear rules look like this:
- Market and timeframe: EUR/USD, 1-hour chart.
- Entry: Buy when the 20 EMA crosses above the 50 EMA and price closes above both.
- Stop loss: Below the most recent swing low.
- Take profit: 2 times the stop distance (1:2 risk-to-reward).
- Risk: 1% of the account per trade.
- Filters: No new trades 30 minutes before high-impact news.
Step 2: Choose your data and time period
Use at least 2 to 3 years of data. Cover different conditions: trending markets, sideways markets, and high-volatility events such as interest rate decisions. A strategy tested only in 2020 tells you how it handles one unusual year.
Step 3: Split the data
Keep the last 30% of your data aside. Build and adjust the strategy on the first 70%. Then run it once, with no changes, on the 30% you held back. This “out-of-sample” test is your best guard against a strategy that only fits the past.
Step 4: Log every trade
For manual tests, open TradingView, pick a start date with Bar Replay, and move forward one candle at a time. Record each trade in a spreadsheet with these columns:
- Date and time
- Direction (buy or sell)
- Entry, stop loss and take profit
- Result in R (risk units): +2R, -1R, and so on
- Screenshot link and a short note
Logging in R units keeps results independent of account size. A loss is -1R. A full winner on a 1:2 setup is +2R.
Step 5: Include real costs
Spreads, commissions and swap fees eat into results. A strategy that makes 1.5 pips per trade before costs may lose money after a 1.2 pip spread. In MT5 Strategy Tester, use “Every tick based on real ticks” mode where your broker offers it. For manual tests, subtract your broker’s average spread from every trade.
Step 6: Reach a meaningful sample
Aim for at least 100 trades. Fewer than 30 trades is noise. With 100 or more, a lucky streak has less effect on the overall numbers.
Step 7: Analyse the results
Calculate the five numbers in the next section. Then decide: keep, adjust, or discard. If you adjust, test the new version on fresh data, not the same period.
5 Backtest Numbers That Matter
| Metric | What it tells you | Rough benchmark |
|---|---|---|
| Expectancy | Average gain per trade in R | Above 0.2R after costs |
| Win rate | Percentage of winning trades | Depends on reward-to-risk |
| Profit factor | Gross profit divided by gross loss | Above 1.3 |
| Max drawdown | Largest drop from a peak | One you can survive emotionally |
| Longest losing streak | Most losses in a row | Plan your risk around it |
How to calculate expectancy
Expectancy = (Win rate × Average win) − (Loss rate × Average loss)
Example: your backtest shows a 40% win rate, an average win of 2R and an average loss of 1R.
(0.40 × 2) − (0.60 × 1) = 0.80 − 0.60 = +0.2R per trade
If you risk R200 per trade (1% of a R20,000 account), each trade earns R40 on average. Over 100 trades, that is about R4,000 before taxes. A 40% win rate looks poor on paper, but the strategy makes money because winners are twice the size of losers.
Why the losing streak matters
With a 40% win rate, a streak of 8 or more losses over a few hundred trades is normal. At 1% risk per trade, 8 losses cost about 8% of your account. At 5% risk, the same streak costs about 34%. Your backtest shows you this before it happens with real money. Our guide to position sizing shows how to set the right risk per trade.
5 Backtesting Mistakes That Give False Results
- Overfitting. You tweak settings until the past looks perfect. A 14-period RSI becomes a 13-period RSI with a 71.5 level. It fits history and fails in live markets. Keep rules simple and use the out-of-sample test.
- Hindsight bias. In manual tests, you see the next candle and “skip” trades that would have lost. Hide future price with Bar Replay and log every valid setup.
- Ignoring costs. Spreads and swaps turn many small-edge strategies into losers.
- Testing one market condition. A trend strategy tested only in trends will fail when the market goes sideways.
- Changing rules mid-test. Finish the test with the rules you started with. Then adjust and retest.
Paper Trading vs Live Trading: What Comes After the Backtest
A good backtest is the first gate, not the last. Use this three-stage path:
- Backtest: 100+ trades on past data. Proves the idea has an edge.
- Demo (paper) trading: 4 to 8 weeks, or 30+ trades, in real time. Proves you can spot setups as they form and follow the rules.
- Live trading with small size: Trade the smallest position your broker allows, or risk 0.25% to 0.5% per trade. Proves you can follow the rules with real emotions.
Compare each stage to the backtest. If your live expectancy is far below the backtest, the problem is often execution, not the strategy. Moving your stop loss is a common cause. See why traders move their stop loss.
Demo trading has one weakness: no money is at stake, so fear and greed stay quiet. That is why the small live stage matters. Our article on trading psychology basics covers what changes when real rand is on the line.
Ready to forward-test your strategy?
Take your backtested rules to AvaTrade futures. Start small and compare your live results with your backtest.
How to Track Performance After You Go Live
Keep the same spreadsheet you used for the backtest. Add two columns: “Followed rules? Yes/No” and “Emotion before entry.” Every month, check:
- Is live expectancy within range of the backtest?
- What percentage of trades broke the rules?
- Did losses cluster on certain days, sessions or news events?
If rule-breaking trades lose more than rule-following trades, you have your answer. Fix discipline before you change the strategy.
Frequently Asked Questions
How many trades do I need for a valid backtest?
Aim for at least 100 trades across different market conditions. Fewer than 30 trades is too small a sample to trust.
Can I backtest for free?
Yes. MetaTrader 5 includes a free Strategy Tester. TradingView offers Bar Replay, and a spreadsheet handles the record-keeping.
Is a profitable backtest a guarantee of future profit?
No. Market conditions change, and real trading adds slippage and emotion. A backtest shows whether an idea has an edge worth testing further on demo and small live accounts.
Should I start with paper trading or live trading?
Start with a backtest, then paper trade for a few weeks, then go live with small size. Skipping straight to live trading means paying the market to test ideas you could test for free.
Affiliate disclosure: Some links in this article are affiliate links. InvestInSA may earn a commission if you open an account through them, at no extra cost to you.
Disclaimer: This article is for education only and is not financial advice. Past performance, including backtested results, does not guarantee future returns. Trading forex and CFDs carries a high risk of loss.