One of the most important parts of trading involves backtesting strategies. Unfortunately, most traders have little or no idea how far to test a strategy. Testing on too brief of a time frame—or one with too few trades—can lead to misleading results. Conversely, using a very wide time frame might miss significant changes within a market and could also miss capturing recent changes in volatility, economic conditions, and market sentiment. So, how do you find the optimal way to backtest a strategy?
That said, a good general rule of thumb when back-testing any swing trading strategy is to go over at least a 10-year period. Better yet, that would fall within a bracket spanning a bull and bear market—a far better way to achieve greater insight into strategy performance in different types of markets. This way, there is also an added advantage in identifying whether this trade would have been able to find long-term market transitions, changed perceived risk, and/or changed economic conditions successfully.
The solution is to find an optimal point between capturing the relevant market cycle and having a statistically relevant sample size of trades. It’s not just the overall time frame that is important; the number of trades and what kind of market conditions you cover during the backtest are just as significant. A perfect backtest balances between being long enough to capture wide market conditions and having enough trades so the results can be trusted.
Things to Keep in Mind When Backtesting a Strategy
1. Backtesting Timeframe
The amount of time you will utilize for backtesting depends a lot on your trading strategy and time horizon. In this case, each type of strategy may deserve a different approach:
Swing Trading:
For swing trading strategies, the position is generally held for several days up to a few weeks. A minimum of 10 years is advisable because this gives you a good number of market cycles to test the strategy from the bull markets down to the corrections. This will provide a wide understanding of how your strategy might perform in various conditions. It’s important that your backtest includes both bullish trends—the market is rising—and bearish trends, where the market is declining, to see how your strategy reacts in each.
Day Trading:
Most day trading strategies rely on short-term price fluctuations and are focused on smaller time frames, such as 5-minute, 15-minute, or hourly charts. Since the day trading strategy does not take into account the long-term trend, it probably doesn’t require such a long backtesting period. A 1-3 year timeframe is often enough to capture sufficient data on daily price movements, especially if you’re using lower timeframes for your trades.
However, even day traders should make sure they test their strategies during different volatility environments. If your strategy takes advantage of extreme market moves, you may need a broader range of data.
Long-Term Investing:
For long-term strategies, including buy-and-hold investing and position trading, you would want a long period, such as 15 or 20 years. Long-term traders have to account for profound changes in market trends and business cycles, even events of a political nature that can cause tectonic shifts in the financial markets. A longer period will allow the testing of your strategy with recessions, economic booms, financial crises, among other forms of market-disrupting events, to give insights into how robust the strategy is.
2. Count of Trades
Where a long period is really important, it does not constitute everything that is in a reliable backtest. In this case, the number of trades included in a backtest comes with equal importance. A backtest performed over a long period with few trades will result in biased results. On the other hand, too many trades over an extremely short period may make a backtest miss the essentials of important market cycles or result in overfitting, where performance is only good during the period being backtested and not in the real market.
The trade count should be such that there is a statistically significant amount to analyze. For a usual test, it might need multiple market conditions, from periods of low to high volatility and around various phases of the economic cycle. For instance, if you backtest your swing trading strategy over 10 years and have only 20 trades, the results might be too few to draw a proper conclusion. The more trades there are, the higher the confidence level will be in the results of the backtest, hence better assessment of how well your strategy is doing in different market conditions.
The more, the merrier: A backtest would ideally have a minimum of 100 trades for decent insights, but that would depend on trading frequency and time period used.
3. Market Conditions
The need for backtesting in various market conditions is huge, and this would give an actual picture of how your strategy is going to perform. Testing in just one market cycle—whether a bullish market, for instance—means you could be losing valuable insights about how it would act in a correction or crash. Why is it important to consider market conditions?
Bull Markets:
In bull markets, the price often goes up steadily for great extents of time, and as a result, most profitability can be obtained from employing trending strategies. A great-performing strategy in a bull market will mostly fail when thrown out of these conditions. As an example, this strategy will fail in sideways or bearish markets with strong volatility, where prices will speed very fast in any of two directions.
Bear Markets:
Bear markets could be a very bad time for any long-only strategy. Nevertheless, some strategies involving short selling or hedging techniques can thrive in a downtrend. Backtesting in bear markets means that your strategy is adaptive to different economic environments and prepared for risk management in case of a downturn.
Sideways Markets:
Market conditions can also be sideways when price action moves within a tight range for an extended period. In such markets, the performance of a trend-following strategy is normally poor, but mean reversion strategies will provide better results since mean reversion strategies assume that prices will revert to their average.
Understanding how your strategy performs in a sideways market helps you avoid relying solely on trends. You should, therefore, incorporate bull and bear markets and sideways market conditions into your test to see how robust your strategy is in performing well across these scenarios.
Conclusion
In the end, your trading strategy’s timeframe, number of trades, and market conditions during the backtesting period, among other things, are what you will base your decision on when it comes to how far back you should go in backtesting a strategy. The best way could be to aim for at least ten years of data, particularly in swing trading strategies, and capture both bull and bear markets.
This period ensures that your strategy will have been tested across different market regimes and that you will, therefore, be in a better position to understand the behavior of your strategy and get a sense of its potential risks. You also want to have enough trades, say over 100, to ensure statistically significant results. It is all about selecting a balance between capturing a relevant market cycle and finding an adequate sample size of trades for the statistical significance of it.