
Backtesting trading strategies
What is backtesting?
Backtesting is an approach that allows you to test a trading strategy's potential future performance by applying that strategy to historical data. It allows you to understand how your trades might have performed in the past, which can then give you clues about how well those strategies might work in the future.
By simulating trades using past price movements, traders can identify strengths and weaknesses in their strategy and then tweak and optimise their trades in line with the test results.
Backtesting can be done manually by examining charts of historical data and calculating how your trades would have performed during those price movements, or by using backtesting tools.
How does backtesting work?
Before you begin poring through reams of historical market data, it’s worth understanding the mechanics of backtesting, the different approaches you can take, as well as its potential and limitations.
Trading strategies
Before you can start testing your trading strategy, you’ll need to clearly articulate its criteria, as any vague trading rules or imprecise parameters will make your test results unreliable or misleading.
So, instead of vague trading criteria like: "buy the stock when its upward momentum looks strong but it isn’t looking overbought”, your strategy would need to specify more precise criteria like "buy when the share price’s 50-day moving average moves above its 200-day moving average and the stock’s Relative Strength Index is still below 70".
Trading parameters
For the results to be as reliable and useful as possible, you’ll also need to define:
The size of the trades
The potential for liquidity constraints that might limit some of your trades from being fulfilled
Likely slippage amounts (including accounting for higher than average slippage during periods of market volatility)
Triggers for any limit orders
Where to set stop loss and take-profit triggers
Historical Market Data
Wheter you decide to do manual backtesting or use backtesting tools, you’ll need historical market data for the markets you’re going to trade. This includes:
Previous price movements
Technical indicators
Trading volumes
and any other market data that might be relevant to your trading strategies.
You’ll also need to decide how far back you want to test. If you are focusing on:
Short-term trading strategies: Historical data covering just a few weeks or months might be enough for your needs.
Planning longer-term trades: You’re going to want to make sure you have historical data that spans multiple years. If possible, this data should ideally cover a variety of different market conditions, from bull markets to bear markets to flat trade.
Market Conditions
If your backtesting is based only on the most favourable market conditions, the results won’t give you a realistic picture of how your strategy might perform during periods of high volatility or sudden downturns.
That’s why it’s important to consider the market environment that existed during the historical data you’re using, and to backtest your strategy across a variety of conditions by selecting different time periods. This helps ensure your approach is robust and adaptable, not just optimised for the best-case scenario.
Why backtest your trading strategy?
There are many reasons to backtest your trading strategy before you begin trading, including:
Strategy Refinement: Even if your trading strategy is sound, there’s often room for improvement. By backtesting your approach before you begin trading, you might discover that slightly adjusting your entry criteria or stop-loss levels could significantly improve the performance of your trades.
Risk Assessment: Backtesting can reveal the Maximum Drawdown (MDD), win rate, Risk to Reward ratio (R/R), and risk-adjusted returns (Sharpe Ratio) that your trading strategy might have achieved in the past, which can then help you set appropriate position sizes on real trades in the future.
Managing Expectations: Many newer traders have overly high expectations in the beginning, so backtesting your trading strategies can help you to manage your expectations, ensuring you don’t overextend yourself unnecessarily.
Confidence: On the other hand, some traders lack confidence in their trading strategies, so backtesting those strategies before real money is on the line can help allay some of those concerns.
What are the limitations of backtesting
Backtesting is a valuable tool that helps traders evaluate and refine their strategies using historical data. However, it does have several important limitations to keep in mind:
Past performance doesn’t guarantee future results: Just because a strategy performed well in historical conditions doesn’t mean it will work in the future. Market conditions, volatility, and external factors can change.
No accounting for emotions or human behaviour: Backtesting removes real-world psychological pressures. In live trading, emotions like fear, greed, or hesitation can lead traders to deviate from their strategy. For example:
Ignoring stop losses
Closing positions too early
Moving or removing take-profit targets
Overfitting to historical data: Some strategies may be unintentionally fine-tuned to perform well on past data but fail to generalise to new market conditions. Doesn’t simulate execution risks: Backtesting assumes perfect trade execution - no slippage, latency, or liquidity issues - which can significantly affect real-world outcomes. In reality, trades may be partially filled, delayed, or executed at worse prices, especially during high volatility or in low-liquidity markets.
How to backtest your trading strategy. 6 Step Process
It’s important to be systematic when you’re backtesting your trading strategies, otherwise there’s a risk that you’ll generate test results that are unreliable or even misleading. The key steps to follow when backtesting are:
Define your trading strategy parameters
Gathe historical data
Run the backrest
Analyse performance
Refine your trading strategy
Forward testing your trading strategy

Step 1: Define your trading strategy parameters
Precise, measurable trading parameters are the key to good backtesting:
Market parameters specify whether you're trading forex pairs, UK equities, indices, or commodities, and which specific assets you’ll be taking positions against.
Time series parameters define the specific historical time frame you'll use when analysing your strategy’s market performance.
Entry criteria must be clear and specific, without the potential for ambiguity, for example, “open a position when the stock’s RSI falls below 30, indicating it has been oversold”.
Position size parameters need to be defined in order to specify how much capital to allocate to each trade. You can use consistent position sizes, percentage-based sizes, or volatility-adjusted sizing, but whichever option you choose, it’s important to define this parameter clearly.
Exit criteria also need to be clear and specific, and should take into account both profit-taking and stop-loss requirements. You should define specific profit targets (for example, "close the position when the price has increased by 8%") and specific stop-loss triggers (for example, "close the position if the price falls below the previous swing low").
It’s important to document all of these parameters in detail before you begin your backtest.
Step 2: Gather historical data
Make sure that the historical data you use is accurate and reliable, and that it covers the specific time frame you need to meet your time series parameters.
Most traders use market data from reliable trading platforms like CMC Markets. Our platform provides extensive historical data across multiple asset classes, much of it going back up to 20 years.
Step 3: Run the backtest
The next step is to apply your strategy’s trading parameters to the historical data.
Apply trading parameters consistently and objectively, ensuring that every signal that meets your criteria is included in the backtest, even if you feel tempted to begin tweaking the trades.
Work through the historical data in sequence, avoiding the temptation to look ahead at future price movements. This prevents look-ahead bias, which can artificially inflate backtesting results.
Record the details of every trade as you go, including entry and exit times, prices, position sizes, and profit or loss amounts.
Step 4: Analyse performance
After you’ve completed the backtest, you’ll need to aggregate all of the trade data together to calculate:
Win rate: The percentage of your trades that were profitable.
Total return: The overall profit or loss your trading strategy produced during the time series you tested
Annualised return: The average yearly return your trading strategy would have produced when the total return figure is annualised
Return on capital: Your total return is calculated as a percentage of the amount of capital you would have required to execute all your trades.
Many traders also like to use additional performance metrics to assess their strategy’s risk-adjusted performance, such as:
Risk-reward ratio (R/R): A ratio that compares the average winning trade size to the average losing trade size.
Sharpe ratio: The Sharpe Ratio compares your strategy’s returns above the risk-free rate to its volatility, essentially measuring how much reward you’re getting for the risk you’re taking.
Maximum drawdown: A measure of the largest peak-to-trough decline during the time frame measured, which can help to estimate your worst-case scenario losses.
When analysing the performance of your trades, don’t forget to factor in costs such as commission charges, spreads, financing charges for overnight positions, and typical slippage - rather than assuming every trade would be executed at the best possible price.
Step 5: Refine your trading strategy
There’s always room for improvement, so it’s a good idea to use the performance data from your backtest to refine and optimise your trading strategy, and potentially run further backtests to test those refinements too.
Step 6: Forward testing your trading strategy
After you have completed your backtest, refined your strategy and backtested those refinements, you can use a demo account to forward test your strategy.
With forward testing, you’ll use a demo account to replicate your refined trading strategy, applying the same rules, parameters, and risk management techniques used during your backtest.
The key difference is that, this time, you’re testing your strategy against real-time market movements rather than historical data, but still using virtual trades instead of risking real capital.
For best results, forward test your strategy across different timeframes and during varied market conditions such as high-impact news events - to see how well your system holds up under pressure.
CMC Markets offers a demo account with £10,000 in virtual funds to help you get started with forward testing.
The amount of historical data you will need for backtesting will largely depend on your trading strategy.
If you’re a day trader or swing trader, then you might only need a relatively short amount of historical data. A few weeks or months might be enough in this case, for example.
If your strategy involves longer-term positions, you’ll need a much larger data set to accurately assess performance across different market cycles.
That said, even with short-term strategies, it’s wise to access a broader range of historical data so you can test your approach across varying market conditions, such as high volatility, low liquidity, or major economic events.
You’ll also want to avoid common data pitfalls like survivorship bias — for example, only using companies that still exist today — or data snooping, where repeatedly testing variations of a strategy can lead to misleading results that don’t hold up in live markets.
The good news? Many platforms, including CMC Markets, offer extensive historical data to help you backtest your strategies with greater confidence and precision.
No, backtesting isn’t the same as paper trading, but the two approaches are related.
Backtesting uses historical data to simulate how your strategy would have performed in the past, whilst paper trading uses dummy trades and real-time data to estimate how your strategy would perform now.
Paper trading is also known as forward testing, and you can use a demo account to do it after you’ve completed your trading backtest.
No, backtesting can help to validate your trading strategy, but it can’t eliminate risk.
Risk is inherent in all financial trading positions, but if backtesting is done correctly, it can help reduce your risk exposure. It’s about calculated risks, rather than eliminating market risk.
*Tax treatment depends on individual circumstances and can change or may differ in a jurisdiction other than the UK.
Disclaimer: CMC Markets is an execution-only service provider. The material (whether or not it states any opinions) is for general information purposes only, and does not take into account your personal circumstances or objectives. Nothing in this material is (or should be considered to be) financial, investment or other advice on which reliance should be placed. No opinion given in the material constitutes a recommendation by CMC Markets or the author that any particular investment, security, transaction or investment strategy is suitable for any specific person. The material has not been prepared in accordance with legal requirements designed to promote the independence of investment research. Although we are not specifically prevented from dealing before providing this material, we do not seek to take advantage of the material prior to its dissemination.

