· 3 min read · Aug 12, 2023
--
In the world of stock trading, various strategies have been developed to identify potential trends and profit opportunities. One such strategy is the “52-Week High Breakout.” This strategy involves identifying stocks that have recently reached or surpassed their 52-week high price and using this breakout as a signal to buy.
In this blog post, we will dive into the concept of the 52-Week High Breakout strategy and conduct a comprehensive backtesting analysis on Nifty 50 stocks to uncover its historical performance.
The 52-Week High Breakout strategy is based on the idea that stocks making new highs are likely to continue their upward momentum. When a stock reaches its highest price in the last 52 weeks, it signals that the stock is gaining positive attention from investors and may have strong underlying fundamentals. So our strategy will try to identify those stocks giving breakouts and like to make buy position.
First, we will try to collect historical price data for Nifty 50 stocks, including daily high, low, open, and close prices, and trading volumes of the last 5 years for our backtesting. The following code downloads the last 5 years of nifty 50 stocks data in a directory.
We will be buying stocks if it's meeting the following conditions:
- Stock is Trading above the 10-day simple moving average (10D SMA).
- Stock’s moving averages are aligned.(10D SMA>20D SMA>50D SMA>100D SMA).
- Breakout Candle should have a closing price higher than the 52 Week High level.
The selling condition can be as follows:-
- When Stock closed below 20D SMA.
We can use the pandas library for calculating 10D SMA, 20D SMA, 50D SMA, 100D SMA, and 52Week High.
Above code will save the PNL% of all stocks into the backtest directory.
Now we need to analyze and combine all PNL% reports for the stocks. The below code calculates the winner and losses stats and plots a frequency distribution chart.
Following is the summary of the backtest result:-
Total Winners: 32
Total Losers: 15
Average Winner Return: 42.66339670952184
Maximum Winner Return: 235.97081117377172
Average Loser Return: -11.134429847209443
Maximum Loser Return: -37.9557995001019
In our strategy we have used 20D SMA as a trailing SL, traders can modify it as per their own analysis and understanding and can get better returns. The above strategy works for a 68%+ percentage of stocks with an average simple return of 42% in the last 5 years, for some, it exceeds 80% as well, which is good.
Thanks for reading!
Thank you for reading until the end. Before you go:
- Please consider clapping and following the writer! 👏
- Follow us X | LinkedIn | YouTube | Discord
- Visit our other platforms: In Plain English | CoFeed | Venture | Cubed
- More content at Stackademic.com