When I started trading, one of the struggles was to come up with a profitable strategy backtested on past data. I was able to come up with many strategies using the fundamentals of trading. But one question still haunted me. I tried searching for the answers in various books, blogs and also talked to many traders about it, but there was no definite answer. The question was on discarding a trading strategy. I needed answers to the following:
- Has a trading strategy stopped working or is it just facing a long drawdown ?
- At times strategy shows good results in the backtest but performs poorly on live markets. Why does it happen ?
I learnt a few techniques to filter out strategies which may look good on paper but are actually bad. I also learnt techniques to stop trading a strategy if it is performing unusually bad.
Overfitting the data
Overfitting is a popular term in the machine learning world. It is one of the key things to understand before backtesting a trading strategy. Overfitting is an evil which makes us think that a trading strategy works super good on past data, but when we trade it on the live market, the strategy does not work at all.
I would not go into the technical definition of overfitting as it may get complex. The important thing is to understand the essence of what it is, so that it can be avoided while creating a strategy. In very simple terms, Overfitting means looking into the data to come up with a strategy which works every time. Now one may ask, isn’t it our goal to come up with a strategy that wins almost 100% of the time. I agree that is the goal, but in coming up with such a strategy we tend to reverse engineer the backtest results itself. For example, say our backtest produced 100 trades in the last 4 years. And we observed that 90% of the trades taken on Tuesday were in loss. We are tempted to specifically remove those trades from the backtests to make the results better. We actually cheated here by looking into the results to improve the results. This leads to super good backtest results, but bad performance in the live markets.
Overfitting can be avoided by using a simple technique. I divide the data into two sets. I will backtest the results on the first set. Once I am satisfied with whatever filters I can think of, I measure the performance of the strategy on the second set. I ensure that both the sets are large enough so that enough data points can be collected. For example, if I have data for 2016 to 2020. I will backtest my strategy for the 2016 to 2018 time period. I will measure the performance of the strategy for the 2019 to 2020 period. This ensures that if backtest results had any bias, the performance would get degraded when tested on the 2019 to 2020 period.
I will be discarding a trading strategy if it performs bad on the second set.
A strategy level stop loss
As I keep a stop loss on individual trades, I also keep a stop loss on the overall strategy. Say my stop loss is Rs. 1 lakh. That means, I will stop trading the strategy if it has made a loss of more than 1 lakh. Now I could be wrong and this could be a regular drawdown, but there is no way to convincingly tell. So being cautious, I will stop trading the strategy all together.
A strategy level stop loss can be easily kept based on the backtest results. Say the results gave a max drawdown of Rs 1 lakh over the backtest period. The trader may keep the max drawdown as the stop loss. One may choose to keep even twice the max drawdown as the stop loss. There is no science here, keeping a strategy level stop loss is completely based on the psychology of individual traders.
It is very important that I decide the strategy level stop loss even before the strategy is put in the live market, else emotions will come play the evil role of not allowing me to discard the strategy once the loss becomes large.
I will be discarding a trading strategy if the strategy level stop loss gets hit.
Keeping a proper position sizing may be one of the most underrated aspects of backtesting. Changing the position sizing method may turn a loss making strategy into a profitable one. I use this powerful technique to even decide if I should continue trading a particular strategy or not.
Say I am trading a strategy with 100 quantities of stock on 10 lakh capital. If the strategy shows a loss of Rs 10,000, that means I have incurred a loss of 1% on my capital. In my next trade, I will reduce my position size by 1%. So I will no longer trade with 100 quantities, instead I will trade with 99 quantities. If a strategy has stopped working, it will keep on giving losses and my position size will keep reducing. This ensures that the long streak of losses happens with an even lesser quantity, thus reducing my overall loss.
Reducing position size helps in two ways. First, it gives me a parameter to judge if the strategy has to be discarded. I can choose to discard the strategy if my position has reduced by say 30%. Again there is no science here, it is upto the psychology of traders. Another benefit is, my strategy level stop loss will be hit much later. Since I will be trading with reduced position as loss happens, my amount of loss will also get reduced. So I have more time to validate. If the strategy is in a longer drawdown, time has come to discard it.
I will be discarding a trading strategy if position size has been reduced by a certain amount.
It is always a tough decision to discard a strategy. There is no definite answer to it. What further makes the decision tough is that the strategy will be discarded when it has already shown substantial losses. Cutting out losses is always hard. But if I always cut my losses small, they will never become big. Trading strategies need to be actively discarded if they do not work.
This is the fourth post of the series “Reminiscence of a retail trader”. Read the introduction post by clicking here.
Follow me on twitter and subscribe to my blog to get all the latest updates on upcoming posts of this series.