How to Backtest a Trading Strategy: Why It Matters and How to Do It

How to Backtest a Trading Strategy: Why It Matters and How to Do It

Backtesting is one of the most tedious, boring jobs we do as traders. It’s also one of the most important, and one of the most overlooked. If you want to give yourself half a chance, you need to treat trading like a business, and backtesting is a core part of that business. Skip it, and you’re setting yourself up to fail. In this article I’ll explain what backtesting is, why it matters, the mistakes to avoid, and three ways to do it.

What is backtesting?

Backtesting means going back in time on historical price data to see how your strategy would have performed.

When I started out in the trading pits in the City of London back in the 1980s, we didn’t have this luxury. Today you can access years of real market data to test your ideas. And remember the law of large numbers: we’re not interested in one trade or the next one. We want to test over a large amount of data.

Why backtest? Four reasons

1. Practice, practice, practice

The footballer practises free kicks, the tennis player practises serves, the darts player practises finishes. Trading is no different. The more you practise applying your strategy rules, the more they become second nature, with no ambiguity and no hesitation when a real setup appears.

2. To find out whether your strategy has an edge

Would your strategy have been profitable over a large sample of trades? You don’t know until you test it on past data. A good backtest doesn’t guarantee future profits. But if a strategy wasn’t profitable in backtesting, it probably isn’t worth pursuing.

3. To understand how your wins and losses are distributed

Remember the coin-toss experiment? Wins and losses arrive in random order, with streaks. If your backtest shows your strategy can lose ten in a row and still be profitable overall, you’ll have the confidence to stick with it when the inevitable drawdown comes.

4. To help manage your emotions

I keep saying psychology is the foundation of trading; I’d say it’s around 70% of the job. We can never remove emotions completely; we’re human. But if you know your strategy’s edge and what its losing runs look like, you’ll be far better equipped to trade it without fear or hesitation.

How to backtest properly

  • Use a written checklist. Write down your strategy rules and tick them off before every trade, exactly as you would with real money. Treat it seriously; it’s the foundation of your business.
  • Avoid hindsight bias. If you know a certain year was great for stocks, don’t run a test that only takes long trades that year. You’ll get an unrealistic result. Pick your test period at random.
  • Journal every result. Don’t keep it in your head. Record every trade.
  • Understand your metrics. Win-loss ratio, profit factor and expectancy all help you judge whether a strategy is really profitable. We cover these in a separate lesson.
  • Beware the cycle of doom. It happens in backtesting too. I’ve seen so many traders start a test, hit a few losses, tweak the rules, and end up throwing away a perfectly good strategy. Set a fixed test period and stick to it before you change anything, and make sure the sample is big enough to judge.

Three ways to backtest

1. TradingView (manual replay)

TradingView has an automated strategy tester for coded strategies, but I prefer to backtest manually. You see how the price action actually played out, and you get a real feel for the strategy.

  1. Set up a multi-chart layout. I use a top-down approach: daily chart bottom right, 4-hour top right, 1-hour on the left.
  2. Sync the charts. In the layout settings, make sure symbol and date range are synced, so all three charts move together.
  3. Use Replay. Select the daily chart, click Replay and pick your starting point. All the charts jump back to the same date.
  4. Mark up the chart as if it were live: support and resistance, liquidity areas, order blocks, moving averages, whatever your strategy uses.
  5. Step forward one candle at a time. You can use auto-play, but stepping one candle at a time is the best way to test.
  6. Use the long and short position tools to plan each trade with entry, stop loss, take profit, account size and risk.
  7. Record every trade in a spreadsheet or trade journal: strategy name, date, entry, % risk, lot size, stop and target. Then review the results: win rate, equity growth and drawdown.

The drawback is that you have to record trades by hand. Honestly, I don’t think that’s a bad thing. It gets you more involved.

2. Forex Tester

My preferred way to backtest is a dedicated tool called Forex Tester. I’m not affiliated with them in any way; it’s just a piece of kit I’ve used for years. It’s paid software, and you can explore the options in your own time.

The advantage is that you can place real orders as you go, including market orders, pending orders, stops and targets, and step through months or years of data quickly. It works out your lot size and risk, and gives you a full statistics report at the end. Almost anything you can do on a live chart, you can do in the backtest.

3. MetaTrader 4 and 5

You can backtest manually on MetaTrader, but it’s more limited:

  1. Right-click the chart and switch off auto scroll and chart shift, or it will keep jumping back to the present.
  2. Scroll back to your starting point.
  3. Press F12 to step forward one candle at a time.
  4. Record your results by hand.

The big limitation is that standard MetaTrader doesn’t sync timeframes, so top-down analysis is awkward. Some third-party add-ons can sync charts. Many years ago I did all my backtesting this way, and it was really hard work.

Backtesting before a prop firm challenge

A prop firm challenge is not the place to find out whether your strategy works. Backtest first, so you know its win rate, its worst losing run and how deep its drawdowns go, then set your risk so that a normal losing streak won’t breach the firm’s limits.

Use your spare time wisely

You can never backtest enough. Bored at the weekend? Do some backtesting. Quiet week with no setups? Rather than forcing trades that aren’t there, do some backtesting. Practice, practice, practice. You won’t regret it.

Frequently asked questions

What is backtesting in trading? Testing a strategy on historical price data to see how it would have performed.

How many trades should I backtest? As many as you reasonably can. The bigger the sample, the more reliable the results, so aim for at least a hundred trades.

Is manual or automated backtesting better? Automated testing is faster, but manual backtesting helps you learn how your strategy behaves and builds your confidence in it.

Can you backtest on TradingView? Yes. Use the Replay feature to step through history one candle at a time, and record your trades in a journal.

Does a good backtest guarantee future profits? No. But a strategy that didn’t work in backtesting probably isn’t worth trading.

Watch the lesson

This article goes with lesson 29 of the Prop Trader Central Masterclass, Backtesting: https://youtu.be/zCkDpBAWmZ8

Trading forex and CFDs involves a high level of risk and may not be suitable for everyone. Most retail accounts lose money when trading CFDs. This article is for educational purposes only and is not financial advice.