MACD for Indian Stocks (Backtesting NIFTY 50)
The increasing accessibility of computational power and public data has recently spurred greater investor reliance on technical analysis techniques. This environment makes it feasible to evaluate and back-test various trading methodologies thoroughly.
Technical analysis aims to derive an optimized approach and make price predictions based on trading data, such as stock price fluctuations and volume changes. This contrasts with fundamental analysis, which examines financial statements for intrinsic worth.
This article is based on a research article called Optimization of Trading Strategies on Indian Stock Market System using Moving Average Convergence Divergence (MACD) Indicator by Regi Kumar and Mekha S.
The study centers on the Moving Average Convergence Divergence (MACD) indicator, a trend momentum indicator developed by Gerald Appel, which is one of the most widely utilized technical indicators in numerous trading methods. The research focused on confirming the effectiveness of optimized MACD strategies, employing the conventional settings of (12, 26, 9).
Methodology and Backtesting Environment
The optimization approach involved backtesting equities listed on the NIFTY 50 index within the Indian stock market. The backtesting period spanned from 2016 to 2022, using market data programmatically downloaded from the Yahoo Finance website. The implementation of the backtesting system was programmed using Python.
Performance was optimized and evaluated based on several key metrics, assuming a risk-free rate of 0. These metrics included the win rate (the probability of making a profit, which must be greater than 50% to be deemed important), number of trades (NT), profitability (P&L) (which ought to be greater than 1), the Sharpe Ratio (SR), the Sortino Ratio, and the Maximum Drawdown (MDD), which highlights the maximum potential losses experienced by investors.
The analysis used the conventional MACD parameters (12, 26, 9) and examined four widely used signal detection rules to gauge the indicator’s effectiveness:
1. Signal line crossover (buy signal when the MACD line crosses over its signal line).
2. Zero crossover (buy signal when the MACD line crosses over zero).
3. Histogram (purchase signal when the last three days are all below zero, and the middle day is the lowest point).
4. Signal line crossover above zero (purchase signal when the MACD line simultaneously crosses above its signal line and above zero).
The Most Profitable MACD Strategy
The optimized outcomes demonstrated that the trading approach significantly improved in terms of win-rate and risk-adjusted performance. However, the comparison of results across the four MACD signal rules revealed substantial variation in effectiveness under the standard (12, 26, 9) parameter setting.
The MACD strategy employing the histogram trading rule recorded the highest success rate among all tested methods, achieving a win rate of 0.64 (64%).
Despite its high success rate and a large volume of trades (836), the profitability metric (P&L ratio) was low, resting at 0.72. A P&L ratio below 1 indicates that the average loss amount was higher than the average profit amount.
In contrast, the MACD technique with the signal line crossover above zero rule proved to be the most profitable, yielding the greatest P&L ratio (2.82) across all tested data sets. This high profitability was achieved despite generating a small number of trades (216). Although profitable, the Sharpe ratio for this technique was 0.35, which is considered “unappealing.
Overall performance analysis indicated that the MACD strategy’s success rate for the data sets was often below 0.5 (50%), and its Sharpe ratios were consistently low.
This evidence suggests that the MACD strategy’s return is “quite hazardous” and that stock volatility affects investors. For instance, the MACD strategy using the zero crossover rule had an incredibly low win rate of 0.38 and a Sharpe ratio of 0.27.
Conclusion
The analysis confirmed that while specific optimized MACD-based techniques can produce a respectable profit, the overall results suggest that performance remains subpar without additional momentum indicators. The study concludes that the MACD signal impulse, specifically the crossing of the MACD line and signal line, initially represents volatility information rather than offering the proper timing for trades.
Although a favorable risk-to-return ratio indicates that these MACD-based techniques are helpful to investors, future research should aim to improve upon these findings by comparing the methods against established benchmarks, other strategies, or return series characteristics.


