← All Posts /

BACK TESTING OF TRADE STRATEGIES

Stock Markets, the most volatile rather fascinating place, is a place where some create a fortune at one end and get broke on the other.

The most exciting thing stock markets teach is the art of proper application of knowledge, patience, and perseverance. There are majorly 3 types of investors in the market:

• Conservatives: Averse to market volatility • Balanced: Can accept moderate volatility • Aggressive: Willing to accept consequences of high volatility. Invests in high-risk and leveraged instruments for high returns. These investors have their trading strategies majorly based on 2 types of analysis: • Fundamental Analysis: Analysing the annual reports of a stock company, its performance and analysing the proper future based on in-depth analysis • Technical Analysis: Analysing chart patterns, finding out the strong demand and supply zones, figuring out the shapes of hammers (shooting star, hammer, bullish engulfing, bearish engulfing, the indecisive Doji, the maribuzo patterns, etc). Constructing a profitable and everlasting strategy

The strategies need to be very accurate, to an extent that its probability of success is much more as compared to its loss. The decisions in the stock market have to be very quick and should have a high probability to result in success (as nothing about the future can be predicted very accurately, the high probability trades need to be identified and the low probability trades are to be rejected).

This synergy of taking and rejecting a particular trade decision can be optimally done when the algorithm is used by the people (which include retail investors, institutional investors, etc). This testing of the trade strategies can be done through a process called BACKTESTING OF TRADE STRATEGIES.

What does backtesting mean?

In simple words, backtesting a trading strategy is the technique of testing a trading hypothesis/strategy on prior timeframes, instead of applying a strategy for the period forward (to judge performance), which could take years, a trader can simulate his or her trading strategy on relevant past data.

For example, say, a trader wants to test a strategy based on the notion that Nifty Bank will outperform the overall market. But if you tested it during the US Financial Crisis, this strategy would not work properly. So, this thing should be kept in mind that backtesting does not necessarily guarantee higher or better returns.

Why do investors backtest their strategies?

Backtesting assesses the viability of a trading strategy by discovering how it would play out using historical data. If backtesting works, traders and analysts may have the confidence to employ it going forward. Another reason for traders to backtest is that they get a clear picture of how the market worked in the past. The trends by the charts show, not a complete, but an elaborate movement of a particular stock, commodity, indexes, currencies, and futures, and options of the same.

The only assumption taken for backtesting is: Any strategy that worked well in the past is likely to work the same way in the future, and conversely, any strategy that performed poorly in the past is likely to perform badly in the future.

Rules to backtest a strategy

• A broad market trend should be taken which includes different market conditions. • Backtesting in a particular sector company would be helpful in the same sector company majorly. As a general rule, if a strategy is targeted toward a particular type of stock, limit the testing to that genre. • Exposure is an important aspect. (It is the amount invested in the market). Increased exposure leads to high risks (which further leads to higher profits or losses), whereas lower exposure leads to lower risk (which further leads to lesser profits or losses). • Volatility measures are extremely significant and hold immense value. Traders should seek to keep volatility low to reduce risk and enable easier entry and exit points in the strategy. • Selecting the time intervals. For a long position, more period for backtesting, and a short buy position, less period for backtesting. Procedure for backtesting

1.Have a trading plan – A proper and systematic trading strategy need to be constructed through proper analysis before starting to backtest it.

Some important aspects to build a trading strategy are:

• Where should you trade? • According to your analysis the trend, the particular market follows? • Entering a buy or a short sell position at different market conditions? • Stop-loss is a particular trade? • Targets needed to be achieved? • How to exit the winning trades?

After answering the questions, a brief algorithm or a strategy can be made so that the strategy can be further used for testing.

2.Heading to previous time frames to understand if the trading algorithm built would have been successful at that moment in the past.

3.Check the results you receive after applying your strategy an appropriate number of times. Say 100 times for each stock, you are willing to trade-in.

4.Leaving the personal bias aside, record the number of times your algorithm worked accurately and the number of times, it gave the wrong outcomes than what was accepted.

AN EXAMPLE

Let a backtesting strategy be:

CONDITION 1 – Buy if the lowest point of the next candle is above the highest point of the previous candle. CONDITION 2 – When the RSI is at 80, then sell, if it is at 20, then buy. (RSI being from 20 to 80). Keeping the stop loss at 20 and 80 respectively.

Try using this strategy on historical data. And then work out the probability of accuracy of this backtesting strategy. Every strategy cannot be the best one. One out of many can be approved to be the optimum strategy.

Common Backtesting measures

• Net profit/Loss • Return: the total return of the portfolio in a specific time frame • Risk-adjusted return: The return of portfolio adjusted for a level of risk • Market exposure: Degree of exposure to different segments of the market • Volatility: The dispersion of returns on the portfolio

Identifying the right one

The future of the trend cannot be predicted, so this concept works on probability. If the probability is greater than half or more precisely and to be on a safer side, is greater than 65%, then the strategy is good to be applied in the live markets. Points to be kept in mind:

• Using proper common sense informing the strategy- E.g. The hypothesis of a trend of Bank Nifty should not be affected by the increase in the price of Apples, as this correlation does not make sense. • Using Blind data – The data should not be chosen which matches the requirements of your strategy. The data should not have a biased movement. This is a mistake which is usually encountered by any trader, unconsciously. • Continue backtesting – Now and then, new demand zones, supply zones, and breakouts can be identified, so backtesting should be continued so that the strategy does not become outdated. • Identify key metrics, indicators, and results before your test- It is recommended to use several different indicators and metrics as well as using multiple data sets whenever possible. This will improve the accuracy of your results. • Be ready to change your strategy – The conditions are highly volatile. It may happen that the strategy may have worked in the past, but it won’t work in the live markets due to a certain event or sudden breakouts in the zones may force the investors to change strategies as the markets change their trends.

Does backtesting help in the markets?

Backtesting is no doubt, a very important aspect in building trading strategies and testing them through historical trends and data. But backtesting has its limitations too. They are:

• Market conditions constantly change. Factors that have affected the market in the past may not affect the market in the present day or the future. • New conditions such as volume, interest rate, and volatility may affect the market differently.

Solution

An integral way to use backtesting, to reduce the adverse effect of the limitations

The best way to get started on trading a new strategy is to keep the leverage minimum and the possible losses under control. After all, losing is inevitable in trading, and losing an affordable amount of money in testing a new strategy may be the best way to go as it can be a vital part of the learning and tweaking process.

Recommended » Benford's Law