How to Backtest a Trading Strategy?

Traders can trade efficiently when they quantify risk and return for their strategy. Analyzing the history and predicting the future behaviour of a trading strategy is at the core of backtesting. It promotes a tested method instead of using quick random tips. This article highlights a step-by-step guide on how to backtest a trading strategy, the best backtesting strategy, and free backtesting software.

Backtesting a Trading Strategy: A Step by Step Guide

Backtesting means testing a trading strategy on the past data to assess its accuracy, without actually investing money. The main premise behind backtesting is that the trading strategy which performed well in the past is likely to perform well in the future and vice versa. Properly executed backtesting with positive results boosts the confidence of traders to move ahead with the strategy. If backtest reflects negative results, traders shall improve or reject the strategy.

Before starting with backtesting, traders check on pre-requisites such as a trading strategy, expected risk and return of the asset, and historical data of the financial assets.

There are two ways for backtesting a trading strategy. One is manually and another is automated backtesting. Manual backtesting is a way by which traders analyze trading strategies on historical data and analyze the results on their own. Automated backtesting is when the software automatically performs a backtest without more manual efforts.

How to manually backtest a trading strategy?

Manual backtesting a trading strategy involves the following steps.

  1. Clearly define a trading plan and in-depth strategy

    A trading plan is developed based on the financial market, trading period, risk level, profit targets, general entry-exit levels, etc. Once the trading plan is defined, a trader defines a further in-depth trading strategy.

    Though traders usually have a raw trading strategy handy, backtesting an unclear strategy would be a waste of time. Here, a trader defines the strategy parameters to have a more clear strategy.

    Strategy parameters aid in evaluating a trading system. Some of the strategy parameters are maximum drawdown, average risk-reward ratio, Sharpe ratio, maximum losing streak, CAGR, etc.

  2. Specify a financial market and timeframe

    Once the trader is clear with a trading strategy, the next step is to clearly define a financial asset and respective market. For example, for the trader willing to backtest a trading strategy for a share/shares, the equity market is the relevant market. It is a forex market in the case of currency pairs.

    Additionally, the trader decides on the period for which the required data for backtesting would be collected. Depending on the strategy, the trader can select an appropriate time. Different time frames, for instance, one-month data and one-year data, provide different results. The trader should select a timeframe that closely reflects the current market environment.

  3. Begin the backtesting of strategy

    As the trader has figured out strategy, market, and time frame, he can start observing the relevant trades in the market in the time frame selected. The trader can further analyze price movements and buy/sell signals according to the strategy.

    From this, he can analyze the gross and net returns to compare them with required capital. If the result matches the expected outcome, he can go ahead with the strategy. If not, the trader shall optimize and improve the strategy.

Example

Samar is manually backtesting a trading strategy of going long when short-term MA goes above the long-term MA, as he thinks this strategy leads to 1.5x more profit. Firstly, he takes a sample period from July 1, 2020, to January 1, 2021. Then, he gets the price data from the sample period and calculates moving averages. Next, he will buy the stock whenever short-term MA crosses above the long-term MA. Then, he can plot the returns and draw a curve and analyze the result. From the result he gets, he can decide whether to go ahead or reject the strategy.

How to backtest a strategy using the software?

The exact steps to backtesting a trading strategy using software differ among different software. Though, common steps are as follows:

  1. Select the relevant financial market and period.
  2. Set up the relevant parameters of trading strategy which can be initial capital, size of the portfolio, benchmark, profit level, stop loss instructions, and so on.
  3. Running a backtest.
  4. Optimizing a strategy if not worked well. (most software provides this feature).

Example

Pranav is backtesting a trading strategy of going short when short-term MA falls below the long-term MA, as he thinks this strategy leads to more profit than the current strategy. He uses one of the software to backtest. He first selects the equity market. Then, he inputs the backtest timeframe from January 1, 2020, to January 1, 2021. Then, he enters the profit target and stop-loss instructions. Finally, he runs a backtest and analyzes the results.

What is the best backtest strategy?

‘The best backtest strategy’ is very subjective. Different traders find strategies most suitable for themselves that differ in terms of trading goals, risk and profit expectations, preferred markets, overall trading experience, and so on.

One of the easy and simple backtest strategies, that even novice traders can consider, is manual intraday backtesting. The traders can look for previous trades on technical charts based on their strategy. This can give them the idea of price movements and profit/loss at those price moments.

Another strategy a trader can consider is performing forward testing along with backtesting. In forward testing, all trades occur only on paper and therefore no money is invested in real. Each trade transaction is recorded along with profits and losses associated with the trading system. Moreover, forward testing considers live data.

Therefore traders can get a clear and reliable picture of how a strategy is likely to perform, as both, historical and real-time data are considered.

Free backtesting software

Backtesting software aids in testing the efficiency of the strategy applied in the past that facilitates the prediction of future performance. There are some free as well as paid software available in the market for backtesting a trading strategy. Some of the free backtesting software are Microsoft Excel, TradingView, NinjaTrader, Trade Station, Trade Brains, etc.

Microsoft Excel is a beginner-friendly backtesting software that involves the use of a set of formulas. Though there are other powerful tools too available, that makes testing a strategy easy and convenient.

TradingView software helps the traders for stock and forex markets. It has a special feature of market replay that facilitates day charts in the timeframe, and strategy tester manual backtesting.

NinjaTrader is another free software available for backtesting that focuses more on futures trading. It facilitates pre-defined sample strategies and 2D/3D optimization graphs.

TradeStation is the broker-connected backtesting software. It eases strategy automation for monitoring positions for traders.

Conclusion

Backtesting is a boon for traders which allows them to test multiple trading strategies without risking huge funds. From small traders to big trading institutions, everyone has access to backtesting. Though it is an efficient method, traders shall not use it solo as past performance does not always reflect future performance. Using it with other technical indicators increases the reliability of results.

Just a few steps to open your FREE Demat Account

We are redirecting you.

OPEN A DEMAT ACCOUNT & Get
FREE Benefits Worth ₹ 5,000

By continuing, I accept the Terms & Conditions and agree to receive updates on Whatsapp

  • 0
    Per Order for ETF & Mutual Funds Brokerage

  • 20
    Per Order for Delivery, Intraday, F&O, Currency & Commodity

Frequently Asked Questions Expand All

While backtesting a trading strategy using Microsoft Excel, first, you need to enter past data of the asset. Next, you can enter technical indicators which can be a stochastic oscillator, exponential moving average, or others. Then, you will have to program enter and exit criteria. Next, enter profit targets and stop-loss levels. Finally, you can analyze the result using various metrics in excel.

There is no such standard time for backtesting a trading strategy. One can decide the time length considering the frequency of trade. If there are enough trades to make a valid assumption, even a shorter time will give reliable results and vice versa.

There is no such standard number of trades that are required to backtest a trading system. It mainly depends on the trading strategy and time frame considered.

Though backtesting a trading strategy is an efficient way, there is no guarantee that it will work. Past performance does not guarantee future results. There is no specific test that can determine the accurate result on how the trading system will behave.