One thing is clear in trading: your strategy needs an edge in the market. The easiest way to find out whether your strategy can make money is to validate it on historical data. This article will teach you how to backtest a trading strategy and what to consider when using a backtesting platform.
What is Backtesting?
Backtesting is an easy way to ascertain the viability of a trading strategy by checking how it performs on historical data. If a strategy performs well in backtesting, it shows that it will likely do well in live trading, giving you the confidence to try it out.
In terms of backtesting definition, it is the process of simulating a trading strategy on the historical price action of a given market. It involves using a backtesting software to replay historical price action so that you can trade the strategy as though it is a live market. In most cases, you also get analytics on the results of the strategy or you can even visualize performance on a chart.
What are the Advantages of Backtesting a Trading Strategy?
Some of the advantages of backtesting a trading strategy include:
- It allows you to validate your trading system on historical data and different market conditions;
- You get the analytics on how the system/strategy worked in the market;
- With those analytics, you can make objective decisions about the strategy so you don’t overestimate its profitability. In this way you’ll avoid risking your hard-earned money on a system that is doomed to fail;
- Backtesting offers you a basis for optimizing the parameters of your strategy;
- You can invalidate very fast wrong assumptions;
- You can test new indicators in just a few seconds without committing real money;
What are the Limitations of Backtesting a Trading Strategy?
Backtesting is great, but it also comes with pitfalls. See below some of the limitations:
- Slippages and delayed order executions may not be taken into account and those factors can affect profitability in the real market setting;
- You need to make sure that trading fees and commissions are included in the overall profitability of the strategy;
- Backtesting alone does not test for the robustness of the trading strategy — a strategy that performed well on backtesting may not perform well in live trading, because the market condition has significantly changed from what it was in the past;
What is a Backtesting Software?
A backtesting software is a web platform or an application that allows you to backtest your trading strategy. It can be a trading platform that has the capacity to replay historical price action along with the readings of any technical indicators so that your strategy can be implemented as though it was in real-time.
There are many free backtesting software options out there that you can use. Yet, those free ones may not offer you everything you need. They usually don’t have enough data and may limit you to a few indicators.
However, there are some good third-party backtesting software that have many built-in technical indicators and drawing tools. These paid ones normally track the most important analytics you need for evaluating the performance of your strategy. Most of them also account for some of the pitfalls like slippages or fees and offer you a robust approach to validate your trading strategies.
The best backtesting software should be simple to use and easy to set up (as it is cloud-based and needs no infrastructure), with enough historical data that is available in multiple timeframes.
How to Backtest a Trading Strategy?
There are certain steps to follow when backtesting trading strategies. While they may vary depending on the nature of trading strategies, these are the key steps to follow:
Step 1: Convert your trading strategy to a trading system
To easily backtest your strategy, you need to convert it to a trading system by writing out the criteria for the various components of your trading system.
Depending on whether you plan to trade in one direction (long-only) or both directions, your trading system should have the following components:
- Entry conditions: the criteria for entering a position. It can have as inputs technical indicators, time-based decisions, portfolio balance or any other factor the trader considers relevant for entering the market.
- Exit conditions: the criteria for exiting a position. Besides the inputs mentioned above, the exit condition can also include some safeties like take profit, stop loss, trailing stop loss etc.
Step 2: Specify the market and the timeframe you want to test the strategy on
Your strategy should be tested for the market you want to trade it in. A strategy that works on S&P 500 Index may not work on gold, while the one that works on gold may not work on Bitcoin. Also, some strategies can be used on the daily candles, while others turn out to be more profitable on intraday levels like 1 minute or 5 minutes.
Step 3: Specify the historical period where you want to test the system
Even if you don’t plan to spare a part of the historical data for walk forward optimization, you need to state the length of your testing period. It’s wise to choose multiple periods with different market conditions.
Step 4: Implement your trading system on the historical price action
Set your backtesting software to replay the historical price action and execute the strategy you want to test. Then follow how your conditions are met for entry and exit.
Step 5: Evaluate results and iterate on your strategy
If you got it from strike 1, then lucky you. But most of the time you need multiple iterations. Don’t lose faith – try again with different inputs and fine-tune your strategy.
How to Evaluate Your Backtesting Results
These are the major performance statistics you must check when evaluating your backtesting results to determine the sustainability of the strategy:
- Number of trades: This tells you whether the results can be repeatable. The lower the number of trades analyzed in backtesting, the less reliable the result.
- Profit factor: This is the total profit divided by the total loss (including commissions) for the entire trading period. It indicates the amount of profit per unit of risk. A profit factor of more than 1 indicates a profitable system.
- Average holding time: This is the average length of time that a position was opened in the market.
- Comparison with Buy and Hold: This shows you how the results of the strategy compare to the passive investing method of buying the asset and holding it all through the backtested period.
- Maximum drawdown: This is the difference between the higher amount and lowest amount your capital reached during the backtesting. A high drawdown is a bad sign.
- Volatility: This shows how your returns fluctuate. The less the volatility, the more suitable the strategy is for that market.
Other statistics to monitor include:
- Profit per trade
- Profit per month
- Win rate
- Sharpe ratio
We learned how to backtest a trading strategy. You can use backtesting as an easy way to ascertain whether a trading strategy can make money by checking how it performs on historical data. Join Vestinda and make sure you add this step in crafting your strategies.
Founder & CEO of Vestinda.
Compacting years of investment portfolio building into just a few minutes.