52-Week High Breakout Backtesting on Nifty 50 (2024)

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:

  1. Stock is Trading above the 10-day simple moving average (10D SMA).
  2. Stock’s moving averages are aligned.(10D SMA>20D SMA>50D SMA>100D SMA).
  3. Breakout Candle should have a closing price higher than the 52 Week High level.

The selling condition can be as follows:-

  1. 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.

52-Week High Breakout Backtesting on Nifty 50 (3)

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:

52-Week High Breakout Backtesting on Nifty 50 (2024)

References

Top Articles
Latest Posts
Article information

Author: Domingo Moore

Last Updated:

Views: 5676

Rating: 4.2 / 5 (73 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Domingo Moore

Birthday: 1997-05-20

Address: 6485 Kohler Route, Antonioton, VT 77375-0299

Phone: +3213869077934

Job: Sales Analyst

Hobby: Kayaking, Roller skating, Cabaret, Rugby, Homebrewing, Creative writing, amateur radio

Introduction: My name is Domingo Moore, I am a attractive, gorgeous, funny, jolly, spotless, nice, fantastic person who loves writing and wants to share my knowledge and understanding with you.