Backtesting: How to test and refine your trading strategy
What is backtesting?
Backtesting is a method of testing your trading strategy against historical data before using it in a live market. The process can help confirm strong and weak strategies before ever opening a position. Aside from ensuring your strategy will actually net you winning traders, backtesting also allows you to experiment with various adjustments to your trading strategy without risking your open positions.
Trading strategies serve to establish entry and exit points for both winning and losing trades. They also establish your position size and, if applicable, the amount of margin you are using. Essentially, trading strategies cement when you will buy and sell a security ahead of when you actually trade.
Backtesting a trading strategy can be performed manually using a free demo account or done with specialized trading software. However, backtesting does not guarantee your strategy will be successful. You should always use additional risk management when trading.
Manual backtesting involves analysing historical market data to identify when a trading strategy would have been triggered, then noting how trade would have performed. In a backtesting hypothetical, trades are closed out by take profits and stop losses.
Automated backtesting leaves the analysis to software. The automated system performs the same analysis you would when manually backtesting and adds up all winning and losing hypothetical trades to determine if the strategy is profitable.
How to backtest a trading strategy
To manually backtest a trading strategy, you need access to historical data for the market you intend to trade. Traders are advised to use several weeks of historical data for short-term trading strategies and up to several years of data for long-term strategies.
Once you have a wide breadth of historical market data, you can follow these steps to backtest a trading strategy:
- Begin looking for entry points: search through your market data and locate the moments your strategy would be triggered
- Follow the trade opportunities through their exit points: analyse the price action following those entry points to see how your trades would perform
- Record the outcome of all trades: tally the amounts won and lost from every trade to find the gross return of your trading strategy. It’s important you include each and every trade that would have been triggered by your strategy, even those resulting in large losses
- Find the net return: Deduct commission fees and other trading costs from the gross return for a more accurate picture of your potential profit or loss
- Calculate a percent return for the total period: Compare your net return over the specified timeframe you analysed to the capital or exposure required to make the trades. This will establish the percent gain or loss you can expect over a given period in relation to the capital you used to trade
The percent return should give you an idea to how successful your trading strategy might be. It is important to check if there are any market anomalies that occurred during the timeframe used or are occurring at the time you intend to trade live. If so, even a successful backtest may be ineffective.
Once you’ve successfully backtested your strategy and are happy with percent return, you can implement your strategy with a FOREX.com trading account. Log in here or open an account in minutes.
If you still want to do further testing, try your strategy in a risk-free environment first with a FOREX.com demo account.
How to automate backtesting
You can automate backtesting using specific trading software. This may be more complicated than just manually backtesting, however. For example, most software requires you to have some grasp of programming and feed the market data into the software.
Some traders claim to use AI like ChatGPT to backtest their trading strategies, but to do so they must input their trading strategy along with all necessary historical market data to get a result. These methods create more opportunities for human error, so they may not be seen as better or worse than manual backtesting.
How to backtest using MT4
MetaTrader 4 (MT4) also has backtesting capabilities using the Strategy Tester tool. To use the tool, you need to build an automated trading program using MT4’s Expert Advisors (EAs). You can then launch the program on the Strategy Tester to receive several reports and quantitative data analysing your trading program.
How to use backtesting in forex trading
Backtesting a forex trading strategy works the same as in other markets, but there are a few considerations to be aware of.
For starters the forex market is open 24/7, but you should only backtest your trading strategy during periods you plan to trade in. Backtesting a forex strategy using all hours of the day is likely to warp results as humans can’t monitor trades 24/7.
Trading on margin is also a major factor of forex trading. Margin requirements vary by currency pair and can change according to your brokerage. Any changes in margin can affect your net return. FOREX.com will notify you in advance if margin requirements for any currency pair are expected to change.
How to use backtesting in share trading
Backtesting a trading strategy for shares or indices works similar to the steps outlined above. It’s important to take note of any market-specific events that occur during your timeframe. For short-term strategies, you may want to backtest with historical data from the quarter you plan to trade in. for longer-term strategies, it’s advised you make note of any one-off global/political events that affected the markets.
It’s also important to include an accurate representation of stocks, even those of companies that were sold or went bankrupt. If you were to only include data of companies still around today, your backtest would likely produce artificially high returns.
Backtesting vs future testing
Backtesting is sometimes compared with future testing, also known as paper trading. In general, backtesting examines how your strategy would perform in past markets, and paper trading is a method of testing your strategy against live markets. Paper trading can be executed via a demo account or any other method that does not require you putting down capital to open positions.
Paper trading can produce more accurate results that backtesting. It shows you how your strategy would perform in the current moment. However, it can’t be ‘sped up’ that way backtesting can. When you backtest against historical market data, you are able to aggregate the results of all possible trades within a timeframe and calculate a net return. This means you can aggregate many trades at once when backtesting compared to waiting for each trade to complete with paper trading.
Pros and cons of backtesting
We’ve covered some of the benefits and pitfalls of backtesting already, but let’s directly compare the two. Here is a full summary of backtesting your trading strategies:
Pros of backtesting:
- It can help raise the chance of successful trades by weeding out bad strategies and confirming better ones
- You gain a deeper knowledge of financial markets while conducting the backtest on historical market data
- Backtesting is risk free and faster than trading on a demo account. Using past market data, you can analyse the outcome of a trade instantly. This is especially helpful for long-term strategies
Cons of backtesting
- Backtesting does not guarantee results. A strategy backtested with a positive net return may not perform as well in live markets for a variety of factors
- Manually backtesting a strategy can be time consuming and requires manipulating large amounts of data
- The software required to automate backtesting can be costly or require programming knowledge
Backtesting is a useful tool to refine any quantifiable trading strategy. However, it’s no silver bullet to profitable trades. Proper risk management like stop losses and trailing stops are still advised for every trading strategy. So is practicing your trades in a FOREX.com demo account.
When you’re confident in your strategy and ready to trade live markets, log in to your FOREX.com account or open a trading account.
StoneX Europe Ltd may make third party material available on this website which may contain information included but not limited to the conditions of financial markets. The material is for information purposes only and does not contain, and should not be construed as containing, investment advice and/or investment recommendation and/or an investment research and/or an offer of or solicitation for any transactions in financial instruments; any decision to enter into a specific transaction shall be made by the client following an assessment by him/her of their situation.
StoneX Europe Ltd makes no representation or warranty and assumes no liability as to the accuracy or completeness of the information provided, nor any loss arising from any investment based on a recommendation, forecast or other information supplied. You should always seek independent advice as to your suitability to speculate in any related markets and your ability to assume the associated risks, if you are at all unsure. We are not under any obligation to update any such material. Any opinion made may be personal to the author and may not reflect the opinion of StoneX Europe Ltd.
CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. 76% of retail investor accounts lose money when trading CFDs with this provider. You should consider whether you understand how CFDs work and whether you can afford to take the high risk of losing your money. Please ensure you fully understand the risks involved by reading our full risk warning.
FOREX.com is a trading name of StoneX Europe Limited, and FOREX.com/ie is a domain operated by StoneX Europe Ltd, a member of StoneX Group Inc. StoneX Europe Ltd, is a Cyprus Investment Firm (CIF) company registered to the Department of Registrar of Companies and Official Receiver with a Registration Number HE409708, and authorized and regulated by the Cyprus Securities & Exchange Commission (CySEC) under license number 400/21. StoneX Europe is a Member of the Investor Compensation Fund (ICF) and has its registered address at Nikokreontos 2, 5th Floor, 1066 Nicosia, Cyprus.
StoneX Europe Limited is registered with the German Federal Financial Supervisory Authority (BaFin). BaFin registration ID: 10160255
FOREX.com is a trademark of StoneX Europe Ltd, a member of StoneX Group Inc.
The statistical data and the awards received refer to the Global FOREX.com brand.
This website uses cookies to provide you with the very best experience and to know you better. By visiting our website with your browser set to allow cookies, you consent to our use of cookies as described in our Privacy Policy.
Through passporting, StoneX Europe is allowed to provide its services and products on a cross-border basis to the following European Economic Area ("EEA") states: Austria, Bulgaria, Croatia, Denmark, Estonia, Finland, France, Germany, Greece, Hungary, Ireland, Italy, Latvia, Liechtenstein, Lithuania, Luxembourg, Malta, Netherlands, Norway, Poland, Portugal, Romania, Slovakia, Slovenia, Spain, Sweden.
Additionally, StoneX Europe Ltd is allowed to provide Investment and Ancillary Services to the following non-EU jurisdiction: Switzerland.
StoneX Europe Ltd products, services and information are not intended for residents other than the ones stated above.
Tied Agent Information: KQ Markets Europe Ltd with Company No. HE427857.
Address: Athalassas 62, Mezzanine, Strovolos, Nicosia Cyprus.
Services Provided: Reception and Transmission of Orders.
Commencement Date: 06/12/2022
Website: KQ Markets - CFD Trading | KQ Markets
We may pay inducements, such as commissions or fees, to affiliates or third-party introducers for referring clients to us. This is in line with regulatory guidelines and fully disclosed where applicable.
StoneX Europe Ltd may make third party material available on this website which may contain information included but not limited to the conditions of financial markets. The material is for information purposes only and does not contain, and should not be construed as containing, investment advice and/or investment recommendation and/or an investment research and/or an offer of or solicitation for any transactions in financial instruments; any decision to enter into a specific transaction shall be made by the client following an assessment by him/her of their situation. StoneX Europe Ltd makes no representation or warranty and assumes no liability as to the accuracy or completeness of the information provided, nor any loss arising from any investment based on a recommendation, forecast or other information supplied. You should always seek independent advice as to your suitability to speculate in any related markets and your ability to assume the associated risks, if you are at all unsure. We are not under any obligation to update any such material. Any opinion made may be personal to the author and may not reflect the opinion of StoneX Europe Ltd.
© FOREX.COM 2025