Spread bets and CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. 73% of retail investor accounts lose money when spread betting and/or trading CFDs with this provider. You should consider whether you understand how spread bets and CFDs work and whether you can afford to take the high risk of losing your money.

How does backtesting work?

Backtesting is a process that involves evaluating the performance of a trading strategy using historical market data. It allows traders to assess the effectiveness of their strategies and make more informed decisions about potential profitability, before risking real capital. Find out how backtesting works generally, and more specifically for MetaTrader 4 (MT4)*.

Discover our MT4 platform

Trade forex, indices, commodities and more, at home or on the move, with MT4.

CMC Markets - Handelsplattform

How backtesting works

  1. Strategy definition: Start by defining the trading strategy you want to test. This includes specifying the entry and exit rules, position sizing, stop-loss and take-profit levels, and any other relevant parameters.
  2. Historical data selection: Choose a set of historical market data that spans a significant period, ideally including various market conditions and price movements. The data should typically include the instrument(s) you want to trade and the relevant timeframes.
  3. Data preparation: Clean and prepare the historical data for backtesting. Ensure the data is free from errors, adjust for stock splits or dividends if necessary, and account for any other factors that may affect the accuracy of the backtest.
  4. Coding or using a backtesting platform: You have two main options for conducting backtesting: coding your strategy using a programming language, or using a dedicated backtesting platform or software. If coding, you'll need to write the necessary code to execute your strategy on the historical data. If using a platform, you'll input your strategy parameters and rules into the software.
  5. Execution and simulation: Once your strategy is coded or set up in the backtesting platform, it’s ready to be executed using your specified historical data parameters. The backtest can generate buy/sell signals based on specified rules, and simulate and track hypothetical trades, positions, and account balance over time.
  6. Performance analysis: After the backtest is complete, you can analyse the results. Key metrics include profitability, win-loss ratio, and average trade duration. Analysis can help you to assess a strategy's viability, and identify areas for potential improvement.
  7. Iteration and optimisation: Based on your performance analysis, you can refine and optimise your strategy as necessary. This may involve adjusting parameters, modifying entry/exit rules, or incorporating additional indicators. It’s then a sensible idea to repeat the backtesting process, assess the impact of these changes, and iterate until you’re satisfied with the results.

Backtesting with MT4

  1. Strategy development: First, you need to develop your trading strategy. This includes defining entry and exit rules, setting stop-loss and take-profit levels, and any other relevant parameters.
  2. Accessing historical data: MT4* provides access to historical price data for various financial instruments like forex, indices, commodities and shares. This data is essential for backtesting your strategy. You can usually download historical data from your broker, or use a third-party service. CMC Markets provides up to 20 years’ historical data.
  3. Open the strategy tester: In MT4, you'll find the ‘Strategy Tester’ option in the ‘View’ menu, or by pressing Ctrl + R. The strategy tester is a dedicated tool for backtesting.
  4. Select an Expert Advisor (EA): In MT4, you can use automated trading algorithms, known as Expert Advisors (EAs), to test and run your trading strategies. You'll need to select an EA that corresponds to your trading strategy, or you can program your own EA.
  5. Configuring backtest settings: Before starting the backtest, you'll need to set the parameters, including the instrument, timeframe, date range, plus any other relevant options. You can also choose to optimise certain parameters, or run the backtest with fixed settings.
  6. Starting the backtest: Once you’ve configured the settings, select the ‘Start’ button in the strategy tester. MT4 will then run the backtest using the historical data you’ve provided.
  7. Reviewing the results: Once the backtest is complete, you can analyse the results. You’ll be able to review total profit/loss, win/loss ratio, and more. Charts help to show the price action curve and trades.
  8. Interpreting the results: This is where you assess the performance of your strategy based on the backtest results. It’s important to remember that past performance doesn't guarantee future results. One factor to consider is how market conditions may have changed since the time period specified in your backtest, and what effect that might have on your next trade.
  9. Refining the strategy: If you’re not comfortable with the results of the backtest, you may need to refine your trading strategy, and perform several backtests.
  10. Weiteres Testen: Once you're satisfied with the backtest results, you can forward-test your strategy on a demo account, or with a small trading size through a live account. This step will help to provide real-time validation of your strategy's performance, and help you to gauge its performance in current market conditions.

Summary

It's important to note that backtesting has limitations. It relies on historical data, which may not reflect future market conditions. Slippage, commissions, and other transaction costs may not be accounted for in backtesting, so real-world performance could differ.

onetheless, backtesting is a valuable tool for gaining insights into the potential effectiveness and robustness of a trading strategy. However, backtesting should be used alongside other forms of analysis and risk management to help you make informed trading decisions.

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.

Before you go…

Try a demo of our Spread Betting or CFD trading accounts on our innovative platform. Free of charge and risk-free with virtual capital starting from €10,000.

cmc-mobile-trading-app