The Ultimate Guide to Backtesting (2024)

Backtesting is a methodical approach where traders evaluate the effectiveness of a trading strategy by applying the rules to historical data to see how the trading strategy would have performed. This technique allows traders to simulate a strategy's performance without risking actual capital to find potentially profitable trading strategies.

The process of backtesting involves selecting relevant historical data, applying the rules of the trading strategy, and then analyzing the outcomes to gauge its potential winrate and profitability.

Backtesting is a very important part of the journey of a trader because it serves as a risk-free testing ground for strategies, offering insights that are crucial for informed decision-making in live trading. It enables traders to identify the strengths and weaknesses of their approach, fine-tune parameters, and develop confidence in their strategy before applying it in real-time market scenarios.

The importance of backtesting for traders cannot be overstated. It is a cornerstone in developing and validating trading strategies, ensuring they are robust and adaptable to various market conditions, and helps traders build confidence in their approach. Moreover, backtesting provides empirical evidence to support or refute the effectiveness of a trading strategy, which is invaluable in a field where objective analysis and data-driven decisions are key to success.

Benefits of Backtesting

Backtesting is a great way to spend your time as a developing trader and especially three benefits stand out.

Risk-free strategy assessment: Performing a backtest does not require a lot of time and within an afternoon, you can easily perform a complete backtest of a strategy to assess the potential performance. Many traders try their strategy on a demo account first but, in my opinion, a backtest is preferable because it takes much less time. Of course, backtest results will never replicate live trading but it is the first important step when it comes to evaluating the potential profitability of a trading strategy.

Getting to know the strategy: Within a few hours, you can go through 30 to 50 trades during your backtest. This way, you can quickly improve your pattern recognition and observe the price action of your trading strategy. This is a great way to get to know your strategy and develop a deep understanding of price behavior.

Improve your confidence: After you have placed 50 backtest trades, you will have a fairly good understanding of what to expect from your strategy. You have collected performance results on your strategy and get a feeling for how it will play out. This is invaluable for your live trading because you already know what to expect. Knowing the average winrate, holding time, and how frequent losing streaks are can boost your confidence and help you push through drawdowns with a strong mindset.

Preparing for Backtesting

Before you get started with your backtest, you have to define a few important parameters.

Historical data: The first question that always comes up when backtesting is how much data you should backtest and how far back you have to go. Here we can simply differentiate between the two broad trading strategy types. When you are backtesting a day trading strategy (15-minute timeframe or lower), it is usually enough to go back two to three months and start your backtest there. When you are backtesting a strategy on a higher timeframe, you will have to go back 6 to 12 months.

Ideally, you want to end up with 30 to 50 trades in your backtest to get a meaningful sample size. Anything below 30 trades does not have enough explanatory power.

Markets: Whereas some trades just backtest one specific market or instrument to evaluate a trading strategy that only performs well on that market, most traders will typically backtest more than one instrument. When you are backtesting multiple instruments, I recommend choosing non-correlated instruments. Correlated instruments will often show a similar performance during a backtest, and it might skew your results.

Trading rules: The goal of a backtest is to evaluate the performance of a trading strategy and, therefore, it is necessary to have a clear plan in mind when it comes to the rules and parameters of your trading strategy. All your backtested trades should look relatively similar and follow the same rules. Before you start backtesting, write out all your trading rules; even better, put them into a checklist format.

You can also search for one perfect trade setup with your chosen rules before you start your backtest. Printing the screenshot of the perfect trade helps you understand what you are looking for.

Different exit approaches: This is my favorite tip and a huge time saver that will make your backtesting so much more efficient. Instead of just backtesting one single trading approach, come up with a few different exit scenarios. For example, you can simultaneously test a 2:1 Reward:Risk Ratio, 3:1, 4:1, and a trailing stop loss approach with the same entry rules. Afterward, you can compare which exit strategy would have performed best. This does not require more effort during your backtest but will already help you find a good exit strategy.

Backtesting Environment

I like to keep it simple when it comes to my backtesting setup. For the actual backtesting, I use Tradingview´s Bar Replay function. And although it has some limitations (mostly when it comes to testing multiple timeframes), you can usually find a workaround.

With the Bar Replay feature, you can define any previous historical starting point and then just go forward candle by candle. I also like to use Tradingview directly because you can apply all your normally used trading indicators and charting tools.

The Ultimate Guide to Backtesting (1)

I find it very important to save screenshots from all the backtested trades for later evaluation. In Tradingview, you can simply save a screenshot with one click and it is automatically downloaded to your computer.

You want to, have at least, save two screenshots per trade. One screenshot from the entry condition and one from the time of the exit. I just create a new folder for each backtest that I perform and then store them on my hard drive.

The Ultimate Guide to Backtesting (2)

Now, to the most important part of your backtest: tracking your results.

You can make it as complicated or simple as you´d like but in the beginning, to just get started, I recommend setting up a simple Excel spreadsheet.

I record the date of the trade, the hour of the day, and the type of trading setup of each trade (columns A, B, and C in the screenshot below). Then, I set up multiple columns for the different exit approaches.

In the screenshot below, I have backtested four different exit approaches from 3:1 Reward:Risk Ratio with passive trade management, trailing the stop loss at the 13-period Moving Average, trailing the stop loss at the 30 EMA, and exiting the trade on a price divergence (row 4, columns D - H).

If you are using the Edgewonk trading journal, you can also save your backtest trades with screenshots in there. You will also be able to get a lot more insights into your backtest performance. But if you just want to get into the flow of backtesting, a simple Excel sheet is a great start.

The Ultimate Guide to Backtesting (3)

Evaluating Backtesting Results

When it comes to evaluating the results of your backtest, we can focus on a few important performance and trading metrics. However, it is important to remember that a sample size of at least 30 (ideally 50) trades is necessary to get statistically significant results.

R-Multiple: The first and most important question is whether the backtest would have made money. When a backtest shows negative results, the strategy cannot be considered going forward.

You also want to avoid strategies that are barely profitable during a backtest. Your backtest results will always be better than the actual live trading results.

Winrate: Although a trading strategy made money during a backtest, if the results show a low winrate, it might be mentally hard to trade such a strategy. A low winrate means more losing trades and the more losses a trader realizes the more likely he is to make mental mistakes. When comparing two backtesting results with similar performance, I would typically go for the one with the higher winrate – even if the results are slightly worse.

Holding time: Many traders struggle with holding onto winning trades. A trading strategy with a long holding time is typically harder to trade and traders are more likely to make errors. I would, therefore, advise going for a trading strategy that has a shorter holding time.

Growth curve: Finally, I look at the growth curve of the backtested strategy performance. The steadier a growth curve is, the better. In the image below, we see two growth curves side by side. Although the performance of the right one is slightly better, it also shows more volatility. The right strategy has longer sideways periods when the account doesn’t grow and then suddenly makes a leap higher. Such a strategy relies on outliers and large winning trades. The left graph shows a steadier growth which is mentally easier to trade.

The Ultimate Guide to Backtesting (4)

Common Pitfalls in Backtesting

Although backtesting is mostly straightforward, traders need to be aware of some common pitfalls to make sure their backtest provides accurate and helpful results.

Overfitting: Overfitting occurs when you backtest the same historical period multiple times and each time you change your trading rules based on your last backtest. Traders will look at their losses and come up with rules on how to avoid them and then backtest the same period again. You will end up with a trading strategy that performs well on your backtesting period, but then fails once you trade it on new data; the strategy is too sensitive and overfitted.

A better approach is to analyze your backtest results, come up with some improvements to your rules, and then backtest the adjusted rules on a completely new historical data period. This is a more robust way of approaching your backtest.

Overlooking losses: Being too optimistic and overlooking losses during a backtest can skew your results. The goal of a backtest is to fully test the rules and sort out all the unprofitable and underperforming strategies; the goal of a backtest is not to “win” a backtest and realize paper profits.

I would rather be too pessimistic when it comes to backtesting than end up with a profitable backtest that immediately falls apart during live trading.

Time of day: When tracking the backtest results, it is always recommended to track the time of the day for each entry and then verify if the entry would have fallen into your active trading times. When the entry time falls into your nighttime or when you are at work, you cannot count the trade in your backtest since you would not be able to take the trade.

Relying on outliers: Looking at the backtest results in the image below, I highlighted a few orange cells. Although the strategy in column F would have realized 16.1 R-Multiple (row 1), 90% of the performance comes from two trades (rows 17 and 29). If a trader misses such outliers, the whole performance falls apart. We already talked about the importance of a steady growth curve previously and relying on outliers for your trading strategy should be avoided.

The Ultimate Guide to Backtesting (5)

Losing streaks: If a trading strategy shows long losing streaks during a backtest, this can also be a red flag. After a long losing streak, emotions will take over, and staying on top of your trading game becomes increasingly harder. I would, therefore, always look for losing streaks in a backtest and avoid strategies with extremely long losing streaks.

Conclusion

In conclusion, backtesting stands as a critical component in the toolkit of any trader. It is not just about validating strategies but also about understanding and mitigating potential risks before they manifest in live trading.

However, it's important to approach backtesting with a healthy dose of skepticism and awareness of its limitations. Overfitting, optimism, and skewed performance are just a few pitfalls that can lead to misleading results.

It's also crucial to recognize that backtesting, while valuable, cannot fully replicate the psychological pressures of real-time trading. As such, it should be complemented with other tools and techniques for a more holistic trading strategy. Ultimately, backtesting is about learning and evolving as a trader, continually refining strategies to adapt to the dynamic world of online trading.

The Ultimate Guide to Backtesting (2024)

FAQs

How to backtest effectively? ›

Here are some tips to ensure effective backtesting:
  1. Consider different market scenarios. ...
  2. Aim to keep volatility as low as possible. ...
  3. Backtest using a relevant set of data. ...
  4. Customise backtesting parameters to meet your specific needs to get accurate results. ...
  5. Be careful about over-optimisation.

What is the best platform to backtest trading? ›

Top best backtesting software for stocks 2024
  1. Amibroker. Amibroker is a comprehensive and highly customizable backtesting platform that allows traders to develop, test, and optimize their trading strategies. ...
  2. TradeStation. ...
  3. MetaTrader 4/5. ...
  4. NinjaTrader. ...
  5. Backtrader. ...
  6. Quant Rocket. ...
  7. Trade Ideas. ...
  8. MultiCharts.
7 days ago

What is the best backtesting software without coding? ›

Tradewell is a backtesting and analytics web app designed to help traders succeed. “A fantastic tool for investors looking for a no-code backtesting tool. Tradewell allows me to make evidence-based trading decisions!”

What are the pitfalls of backtesting? ›

Limited data quality: Backtesting relies on historical data, and the quality and accuracy of the data used can have a significant impact on the results. Data may contain errors, gaps, or other inconsistencies, which can distort the backtest results and lead to inaccurate conclusions about the strategy's performance.

How much backtesting is enough? ›

Aim for at least 200 trades in your backtest, but 500-600 offers even greater reliability for informed decision-making. Beware of "Data Fatigue": Excessively long backtests can mislead you by including drastically different market regimes.

What are the basics of backtesting? ›

Backtesting involves applying a strategy or predictive model to historical data to determine its accuracy. It can be used to test and compare the viability of trading strategies so traders can employ and tweak successful strategies.

Where can I backtest my trading strategy for free? ›

AlgoTest - Free Backtesting Options Trading Strategies in India.

Which platform do professional traders use? ›

IC Markets' clients have access to a good range of professional platforms – MT4, MT5, and the cTrader platforms. All of these provide excellent charting tools and indicators and can run algorithmic trading strategies 24/7 using the IC Markets VPS service.

Are there any free backtesting software? ›

MATATrader is a free and open-source software that offers a wide range of charting and backtesting tools for technical analysis. It is known for its user-friendly interface and extensive customization options. The platform also provides access to real-time market data and supports multiple programming languages.

Is TradingView good for backtesting? ›

It allows you to test your strategy on historical data to determine its viability before risking real capital. TradingView has become one of the most popular platforms for backtesting strategies, with its easy-to-use interface and variety of built-in tools.

How do you manually backtest a trading strategy? ›

How to backtest a trading strategy
  1. Define the strategy parameters.
  2. Specify which financial market​ and chart timeframe​ the strategy will be tested on. ...
  3. Begin looking for trades based on the strategy, market and chart timeframe specified. ...
  4. Analyse price charts for entry and exit signals.

Can you backtest on TradingView for free? ›

Yes, you can backtest for free on TradingView using the platform's Bar Replay and Strategy Tester features. However, it's important to note that the free BASIC subscription on TradingView limits users to daily chart data for backtesting.

What is an example of a backtest strategy? ›

Example of Backtesting

An investor uses a 50-day moving average as a trading strategy for a stock, and starts to collect price data going back to 2018 as a way to determine whether the stock can match similar returns in the future.

What is a good sample size for backtesting? ›

Ideally, you want to end up with 30 to 50 trades in your backtest to get a meaningful sample size. Anything below 30 trades does not have enough explanatory power.

How far back should you backtest? ›

If your trading system generates three trades per day, i.e. 600 trades per year, then a year of testing gives you enough data to make reliable assumptions*. But if your trading system generates only three trades per month, i.e. 36 trades per year, then you should backtest a couple of years to receive reliable data.

How accurate is backtesting? ›

Backtesting is not always the most accurate way to gauge the effectiveness of a given trading system. Sometimes strategies that performed well in the past fail to do well in the present. Past performance is not indicative of future results.

Top Articles
Latest Posts
Article information

Author: Chrissy Homenick

Last Updated:

Views: 6518

Rating: 4.3 / 5 (54 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Chrissy Homenick

Birthday: 2001-10-22

Address: 611 Kuhn Oval, Feltonbury, NY 02783-3818

Phone: +96619177651654

Job: Mining Representative

Hobby: amateur radio, Sculling, Knife making, Gardening, Watching movies, Gunsmithing, Video gaming

Introduction: My name is Chrissy Homenick, I am a tender, funny, determined, tender, glorious, fancy, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.