Backtesting in trading

David Banks
Authored by David Banks
Posted Monday, September 20, 2021 - 8:04am

Before a trader goes into the market and risks his capital, one of the most important things he must do is understand his trading strategy. Looking back through historical trading data gives one an idea of how the strategy performed and if it can be replicated in future trades. 

Backtesting refers to testing your trading strategy on historical data and analysing its performance over time. This will show where the strategy stood out and where it fell short. It helps to generate results and evaluate risks and profitability without the risk of losing actual capital. The idea of backtesting is based on the theory that financial markets run in cycles. A strategy may be assumed to be viable going forward because it worked in the past.

Traders who continuously backtest their strategies gradually become better and build confidence, based on numerous tests, data, and analyses. 

Automatic Vs Manual Backtesting

The first is to use a script to automatically run your backtest. If one understands coding, it can be a much faster method.

The second option is to backtest manually using MS Excel or other tools. One can use charts with past prices to find setups that you would like to test for with your trading strategy. One can then use trend lines, indicators and other tools to analyse the results. Future prices should be kept hidden to avoid bias.

Define Your Trading Strategy

For a beginner, this will definitely be a daunting task. Before backtesting can be done, one must have a trading that indicates the set of rules and conditions that guide the trading decisions, especially for the long-term investments. The trading plan must answer the following questions:

  • What are the conditions of your trading setup?
  • How much do you risk per trade?
  • Which timeframe are you trading?
  • Which markets are you trading?
  • What is your entry trigger?
  • Where is your stop loss?
  • How will you exit your winners?

Backtesting can proceed upon completion of the trading plan. It is one of many trading strategies that can be applied for trading.

Backtesting

How backtesting works

Backtesting performs analysis on selected historical data and simulates trades for every matched stock only if there are vacant positions in the portfolio. Typically, there are few stocks in the portfolio since the purpose is to control risk (20-30). If some stocks conform to the criteria set, stop loss, or take profit condition, the corresponding position will be closed. Stocks that were purchased earlier are sold and will be reflected in the simulated trade. The position is then closed which allows for vacancies in the portfolio. 

Backtesting Strategies

These are some of the most common statistics traders seek out:

  • Averages – average gain and average loss, given in percentage
  • Net Profit/Loss
  • Return - the percentage of return over a given time frame
  • Volatility – measures how drastically a market’s prices change
  • Win/loss ratios

Key Tips for Effective Backtesting

There are a few effective rules and processes every trader should practise:

  1. Start with a specific measurable idea – One needs to understand the exact parameters to be evaluated. The more the specific you are, the better the results will be. 
  2. Ensure the hypothesis is simple – if the hypothesis is too complicated it would lead to inaccurate conclusions that would throw off the results. 
  3. Identify the Metrics and Indicators before the test – this will avoid bias
  4. Factor in Different Market Conditions – consider whether it is a bull market, bear market or a hot sector. Testing trading strategies in all these conditions will give more robust results. 
  5. Get the Right Tools – choosing the right tools depends on many factors including what one wants to accomplish and the resources at their disposal. 

Why Does one need to backtest?

Backtesting helps traders to determine several facts:

  1. Helps to prove if the strategy is effective –  Backtesting historical data lets the users witness the way they want their plan to perform. 
  2. Helps in optimizing the approach – it is necessary to find a good balance between comfort and profitability.
  3. Helps in generating trading ideas – One will come across several repetitive patterns that will catch their attention. Identify those strategies that work and which will not.
Share this