OPEN-SOURCE SCRIPT
Telah dikemas kini ✨Smart Option MACD: Bullish, Bearish, Neutral Logic by AKM ✨

The **Smart Option MACD: Bullish, Bearish, Neutral Logic by AKM** is an advanced indicator designed for TradingView, tailored for option traders on indices like NIFTY. It automates options trend scanning by applying MACD analysis to both Call (CE) and Put (PE) options near the ATM (At-The-Money) strike, providing actionable market states—Bullish, Bearish, or Neutral—using distinct logic for both strikes and overall market context.
***
### Core Features
- **Option Selection Logic:** The script dynamically calculates ATM, CE, and PE strike prices based on the underlying index spot price and customizable user inputs for expiry, strike distance, and OTM/ITM shift.
- **MACD on Option Prices:** For both CE and PE symbols, the indicator computes the MACD (Moving Average Convergence Divergence) and Signal lines. It uses standard MACD settings: 12-period EMA (fast), 26-period EMA (slow), and 9-period Signal.[2][5]
- **Strike Status Classification:**
- AZL 🔼: Indicates MACD > 0 for that option, signifying positive momentum.
- BZL 🔽: Indicates MACD 0 & crossover up), PE is bearish (MACD<0 & crossover down).
- **Bearish:** PE is bullish & crossover up, CE is bearish & crossover down.
- **Neutral:** All other scenarios—including mixed or undefined signals.
***
### Table Output
A real-time table is displayed on the chart (top-right) with key option and market details:
- Spot price
- ATM Strike
- CE/PE strike status (momentum + crossover logic)
- Option prices
- Overall market state, color-coded for clarity
***
### How to Use This Indicator
- **Entry Signal:** Use the Bullish/Bearish status for directional trades or option strategies. Bullish calls for buying or selling upward momentum options; Bearish favors downside trades. Neutral advises caution or range-bound trades.[5][13]
- **Customizability:** Expiry, strike width, OTM/ITM offset, and chart resolution are user-controlled, allowing adaptation to different market contexts.
- **Best Practice:** Use alongside price action, support/resistance zones and other indicators to confirm options momentum, as MACD is powerful yet not infallible.[5]
***
### Who Is It For?
- **Option traders** who want to automate trend/momentum detection for CE/PE strikes instead of manual chart switching.
- **Index traders** (NIFTY, BANKNIFTY...) seeking systematic edge in intraday/positional strategies tied to option momentum.
- **Technical analysts** interested in visual, rule-based signals combining options data and classic MACD logic.
***
The Smart Option MACD indicator streamlines multi-strike, multi-option momentum analysis and presents clear actionable logic directly on your chart for enhanced decision-making. Use it as a core part of your TradingView toolkit for options-focused market views.
***
### Core Features
- **Option Selection Logic:** The script dynamically calculates ATM, CE, and PE strike prices based on the underlying index spot price and customizable user inputs for expiry, strike distance, and OTM/ITM shift.
- **MACD on Option Prices:** For both CE and PE symbols, the indicator computes the MACD (Moving Average Convergence Divergence) and Signal lines. It uses standard MACD settings: 12-period EMA (fast), 26-period EMA (slow), and 9-period Signal.[2][5]
- **Strike Status Classification:**
- AZL 🔼: Indicates MACD > 0 for that option, signifying positive momentum.
- BZL 🔽: Indicates MACD 0 & crossover up), PE is bearish (MACD<0 & crossover down).
- **Bearish:** PE is bullish & crossover up, CE is bearish & crossover down.
- **Neutral:** All other scenarios—including mixed or undefined signals.
***
### Table Output
A real-time table is displayed on the chart (top-right) with key option and market details:
- Spot price
- ATM Strike
- CE/PE strike status (momentum + crossover logic)
- Option prices
- Overall market state, color-coded for clarity
***
### How to Use This Indicator
- **Entry Signal:** Use the Bullish/Bearish status for directional trades or option strategies. Bullish calls for buying or selling upward momentum options; Bearish favors downside trades. Neutral advises caution or range-bound trades.[5][13]
- **Customizability:** Expiry, strike width, OTM/ITM offset, and chart resolution are user-controlled, allowing adaptation to different market contexts.
- **Best Practice:** Use alongside price action, support/resistance zones and other indicators to confirm options momentum, as MACD is powerful yet not infallible.[5]
***
### Who Is It For?
- **Option traders** who want to automate trend/momentum detection for CE/PE strikes instead of manual chart switching.
- **Index traders** (NIFTY, BANKNIFTY...) seeking systematic edge in intraday/positional strategies tied to option momentum.
- **Technical analysts** interested in visual, rule-based signals combining options data and classic MACD logic.
***
The Smart Option MACD indicator streamlines multi-strike, multi-option momentum analysis and presents clear actionable logic directly on your chart for enhanced decision-making. Use it as a core part of your TradingView toolkit for options-focused market views.
Nota Keluaran
### COI Logic (Change in Open Interest)
- **COI stands for Change in Open Interest**. This logic analyzes the change in open interest for current and next month's futures contracts.
- The script calculates COI as:
- $$ \text{COI} = (\text{Current Month OI Change}) + (\text{Next Month OI Change}) $$
- It uses daily close values for futures to approximate the open interest change for both the current and next month contracts.
### How COI & Price Are Used
- The combination of **spot price change** and **COI** helps determine the market position regarding whether participants are building (adding), unwinding (removing), or covering positions.
- The status is dynamically determined by comparing both COI (oiChange) and spot price change (spot_per).
### Open Interest Status Mapping
| COI (oiChange) | Spot Price Change (spot_per) | Status | Meaning |
|:--------------:|:---------------------------:|:-----------------|:--------------------------------|
| Positive | Positive | Long Buildup | Fresh Long positions added |
| Positive | Negative | Short Covering | Shorts are being closed |
| Negative | Positive | Long Unwinding | Long positions are being closed |
| Negative | Negative | Short Buildup | New Short positions added |
| Zero | Any | Neutral | No significant activity |
**Color Coding** is used for quick visualization:
- Long Buildup: lime
- Short Covering: green
- Long Unwinding: orange
- Short Buildup: red
- Neutral: gray
### Purpose
This logic is displayed in the script's output table for clear, real-time tracking of market sentiment through open interest analysis. It helps traders quickly interpret whether the current market action is dominated by new buying, new selling, profit booking, or covering of positions.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.