OPEN-SOURCE SCRIPT

Theta Decay Tracker [AlgoChief]

317
Theta Decay Tracker [AlgoChief]

What This Indicator Does

When you're holding an option and the underlying index moves, the option's premium doesn't always move the way you'd expect. Part of the gap is Delta (how much the option should move per point of index movement), and part of it is Theta (time decay) eating into your premium — even when the index hasn't reversed.

This indicator separates those two effects on every candle, so you can see exactly how many points you lost purely to time decay, independent of index direction.

How It Works (Logic)


Fetches the underlying index price (NIFTY, BANKNIFTY, FINNIFTY, MIDCPNIFTY, SENSEX, or any custom symbol) alongside your option chart, using request.security on the same timeframe (no repainting, no lookahead).
Solves Implied Volatility live from the option's own closing price using a Newton-Raphson iteration on the Black-Scholes formula — no need to manually check the option chain for IV.
Calculates real-time Delta and Theta using the standard Black-Scholes model (Strike, Time-to-Expiry, IV, Risk-Free Rate).
Compares actual vs expected move, every candle:

Expected Option Move = Delta × Index Move
Decay = Actual Option Move − Expected Move


If Decay is negative while the index barely moved, that gap is mostly time decay (plus minor vega/gamma effects).
Tracks cumulative decay over a configurable lookback window (e.g., last 15 candles) and fires an alert when decay crosses your threshold while the index stays flat/no reversal — this is the clearest signal of pure theta bleed.


How to Use It


Add the indicator to your option's chart (not the index chart).
In settings, pick your Index Preset (NIFTY/BANKNIFTY/FINNIFTY/MIDCPNIFTY/SENSEX) or choose Custom and enter your own symbol.
Enter the Strike Price, Option Type (CE/PE), and Expiry Date & Time.
Leave "Auto-solve IV" ON (recommended) — it reads IV directly from the option's live price.
Adjust the Decay Alert settings:

Lookback (bars) — the time window to check
Decay Threshold — how many points of unexplained loss triggers an alert
Flat Threshold — how much index movement still counts as "no reversal"



Set a TradingView alert on "Theta Decay Threshold Hit" to get notified in real time.


What It Helps With


Knowing whether your option is losing value because the index moved against you, or purely because of time decay — critical for deciding whether to hold, exit, or roll a position.
Spotting theta acceleration near expiry, especially during range-bound/sideways sessions.
Avoiding the common mistake of blaming "index isn't moving enough" when the real issue is decay eating the premium regardless.
Works on any NSE/BSE index option (or global index options via Custom symbol).


Panel Elements


Green/Red columns: Decay per candle (green = option outperformed delta expectation, red = decayed more than expected)
Orange line: Theoretical Black-Scholes theta/day, for reference
Purple line: Cumulative decay over your lookback window
Red background zone: Marks bars where the decay alert condition is active
Table (top-right): Live IV, Delta, Theta/day, Index move, Expected move, Decay, and Cumulative decay


Important Notes / Disclaimer


This is a Black-Scholes approximation, not a live options-chain feed. The "Decay" value bundles theta with minor vega/gamma effects — it is not a pure isolated theta number.
IV is solved from the option's own price using Newton-Raphson; in illiquid/wide-spread strikes, solved IV can be noisy on individual ticks — use candle-close values for reliability.
This tool is for educational and analytical purposes only. It does not predict future price movement and is not financial advice. Always do your own due diligence before making trading decisions.
Works best on liquid strikes (near or at-the-money) where bid-ask spreads are tight and Black-Scholes assumptions hold reasonably well.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.