post-thumb

How to do Backtesting in Share Market?

Backtesting is one of the most important stepping stones towards becoming a professional trader. As a trader we have several strategies, thumb rules, and we use several indicators. But until and unless we have backtested all of these, we run a high risk of losing our money.

In this article, we are going to learn about the concept of backtesting, how it’s done, the tools available for us to fasten this process, etc.

Table of Contents
  • What is Backtesting?
  • How to do Backtesting?

What is Backtesting?

In backtesting we use old data and charts to test our trading strategies, indicators, etc. Once you have backtested all these across a large data, you will get a lot of information regarding their efficiency, pitfalls, risk zones, etc.

We should backtest all these before using them in live trading:

  • Trading Strategies
  • Various candlestick and chart patterns
  • Various indicators, such as RSI, Moving Averages, etc.

How to do Backtesting?

There are various software available in the market that will help you in this effort, e.g. in.tradingview.com or tradingview.com, Amibroker, etc. These will allow you to test your strategy/indicator over a lot of data (even spanning multiple years), that too within seconds.

These software allow us to code our strategies and even make our own indicators (e.g. in Tradingview we use Pine Script for this purpose). Then we can run these scripts on the previous-year charts provided by these software.

Note

There are many readymade scripts available in Tradingview – both made by the company, and those published by various users. You may utilize these strategies, test them, improve them, and you are done. Learning Pine Script is not that hard. Good quality documentation is available on Tradingview. The Pine Editor also provides us valuable tips while we are coding/modifying the code. Many good quality video lectures and articles are also available on the internet regarding the same.

In the results section, you will be provided a lot of information regarding the performance of your strategy. However, give special attention to the following:

  • Profitability: Of course, the first thing you should look out for is the profitability of the strategy. It must be profitable. Also, the ratio of the amount of profit to amount of loss per trade must be over 1.
  • Percentage of profitable trades should be high. Have a look at all the dimensions of trade. Say you are placing both call and put trades, then make sure that both are having a healthy percentage of profitable trades.
  • Number of trades: The number of trades taken should be on the lower side, as more the number of trades, more the commission costs you will have to pay.
  • Maximum Drawdown: Have a look at the maximum drawdown, especially the maximum drawdown percentage. It shows the maximum percentage of capital lost during the given trading period. For example, if maximum drawdown percentage is 50%, it means that at least once during that time-frame you would have lost 50% of your capital. It should be as low as possible – it’s a big risk factor!
Warning

It’s prudent to do some manual testing too, mainly because of two reasons:

  • There maybe some things that cannot be tested using these software, e.g. some candlestick patterns, or chart patterns.

  • These backtesting software are not completely bug free. So, do not blindly rely on the results shown by them. Always double check by checking at least some trades manually.

After backtesting you should analyze the result data, and note down the weak areas in the strategy. For example, it may be having good profit-loss ratio and percentage of profitable trades, but the maximum drawdown may be too high. Or maybe, your strategy works well in case of call trades, but is loss-making in case of put trades.

You need to go back to the drawing board, rectify the pitfalls, and enhance your strategy. Sometimes, only a few minor tweaks are required. Then you may backtest the strategy again. Do it again and again till you get your holy grail trading strategy.

Note

Apart from backtesting, websites like Tradingview also help us in various other ways. For example, you may use it for:

  • Comparing charts of various indices and stocks.

  • In premium versions, you may use the replay feature, wherein you may go back in time and see the charts develop in front of your eyes once again. It’s really good for practice. You may also paper trade with fake money.

There are numerous other features of this platform that you may explore once you start using it. Otherwise, it’s going to be a very long list.

Winding Up

Keep in mind that if a strategy has been successful in backtesting, it only means that it has proven it’s worth in the past. So, it increases the probability of that strategy to be profitable in the future too. The key word is “probability”. It’s not certain that it will work in the future.

However, many businesses are built on the logic and concepts of statistics and probability. For example, in casino business the probability is stacked in favour of the house, rather than the players. This is what makes them profitable in the long run. Similarly, insurance business is based on statistics and data – the potential customers, premium amount etc. are decided upon through past data analysis. Both of these concepts are applicable in stock markets too.

  • Analysis of past data can give us precious insights.
  • There’s nothing certain in trading. We just have to ensure that our success probability is as high as possible.

Backtesting of our strategy allows us this edge. It increases our chances of making profits.

Moreover, it’s essential that you also forward test your strategy. Do paper-testing of that strategy on future data for some time. If it seems suitable, use it in live trading but with small capital. Do it at least for 3-4 months. If you are satisfied with the results, you may increment the capital in a phase-wise manner.

Share on:
comments powered by Disqus