Indicator · Pine Script v6 · On the chart

Expiration Highlights: Opex, Quarterly Opex & VIX with Vanna/Charm

by namuan

This indicator identifies and plots key options expiration dates on the price chart.

View on GitHub

GitHub stars318on the repository
Pine versionv6current
Lines of code117
Settings12inputs
LicenceMIT
Last update2 months ago18 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

117 lines of Pine Script v6 from tv-scripts/expiration-highlights.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

expiration-highlights.pine
//@version=6
indicator("Expiration Highlights: Opex, Quarterly Opex & VIX with Vanna/Charm", overlay=true, max_lines_count=500, max_labels_count=500)

// ==========================
// Inputs (customizable)
// ==========================
showOpexLines   = input.bool(true,  "Show monthly opex lines")
showQuarterly   = input.bool(true,  "Show quarterly opex lines")
showVIXLines    = input.bool(true,  "Show VIX expiration lines")

vannaStartDays  = input.int(11, "Vanna/Charm start (days before opex)", minval=5, maxval=20)
endVannaOnTue   = input.bool(true, "End vanna/charm on Tue of opex week")

startWeakOnWed  = input.bool(true, "Start weakness on Wed of opex week")
endWeakNextTue  = input.bool(true, "End weakness on Tue after opex")

colOpex     = input.color(color.new(color.blue, 10),   "Opex line color")
colQuarter  = input.color(color.new(color.purple, 10), "Quarterly opex line color")
colVIX      = input.color(color.new(color.orange, 10), "VIX line color")
colVanna    = input.color(color.new(color.green, 85),  "Vanna/Charm fill")
colWeak     = input.color(color.new(color.red,   85),  "Weakness fill")

// ================
// 1) Monthly Opex
// ================
isOpex = (dayofweek == dayofweek.friday) and (dayofmonth >= 15 and dayofmonth <= 21)

// Quarterly months: Mar (3), Jun (6), Sep (9), Dec (12)
isQuarterlyOpex = isOpex and (month == 3 or month == 6 or month == 9 or month == 12)

// Helper: is current bar in "opex week"? (Friday of this week is 15..21)
f_isOpexWeek() =>
    toFri = dayofweek.friday - dayofweek
    toFri < 0 ? false : (dayofmonth + toFri >= 15 and dayofmonth + toFri <= 21)

// =========================
// 2) Next month + VIX exp
// =========================
yearCur  = year(time)
monthCur = month(time)
nextMonth = monthCur == 12 ? 1 : monthCur + 1
nextYear  = monthCur == 12 ? yearCur + 1 : yearCur

// Find 3rd Friday of next month
var int thirdFriNext = na
thirdFriNext := na
for d = 15 to 21
    if dayofweek(timestamp(nextYear, nextMonth, d)) == dayofweek.friday
        thirdFriNext := d
        break

targetOpexTime = timestamp(nextYear, nextMonth, thirdFriNext)               // next month's opex
vixExpTime     = targetOpexTime - 30 * 24 * 60 * 60 * 1000                  // ~30 days earlier
vixYear  = year(vixExpTime)
vixMonth = month(vixExpTime)
vixDay   = dayofmonth(vixExpTime)
isVIXexp = (dayofweek == dayofweek.wednesday) and (year == vixYear) and (month == vixMonth) and (dayofmonth == vixDay)

// =====================================
// 3) Draw vertical lines (line-throttle)
// =====================================
var int lastOpexBar = na
var int lastQuarterBar = na
var int lastVIXBar  = na

if showOpexLines and isOpex and (na(lastOpexBar) or bar_index - lastOpexBar > 5)
    line.new(bar_index, high, bar_index, low, extend=extend.both, color=colOpex, style=line.style_solid, width=2)
    lastOpexBar := bar_index

if showQuarterly and isQuarterlyOpex and (na(lastQuarterBar) or bar_index - lastQuarterBar > 5)
    line.new(bar_index, high, bar_index, low, extend=extend.both, color=colQuarter, style=line.style_dotted, width=2)
    lastQuarterBar := bar_index

if showVIXLines and isVIXexp and (na(lastVIXBar) or bar_index - lastVIXBar > 5)
    line.new(bar_index, high, bar_index, low, extend=extend.both, color=colVIX, style=line.style_dashed, width=2)
    lastVIXBar := bar_index

// ===================================
// 4) State flags for shaded windows
// ===================================
var bool inVanna    = false
var bool inWeakness = false

// Convenience checks
f_isMondayBeforeOpexWeek() =>
    (dayofweek == dayofweek.monday) and (dayofmonth + vannaStartDays >= 15 and dayofmonth + vannaStartDays <= 21)

f_isWedOfOpexWeek() => (dayofweek == dayofweek.wednesday) and f_isOpexWeek()
f_isTueOfOpexWeek() => (dayofweek == dayofweek.tuesday)   and f_isOpexWeek()

// ---------------------------
// Start windows
// ---------------------------
if not inVanna and f_isMondayBeforeOpexWeek()
    inVanna := true

if not inWeakness and startWeakOnWed and f_isWedOfOpexWeek()
    inWeakness := true

// ---------------------------
// Determine background color
// ---------------------------
color bg = na
if inWeakness
    bg := colWeak
else if inVanna
    bg := colVanna
bgcolor(bg)

// ---------------------------
// End windows
// ---------------------------
if inVanna and endVannaOnTue and f_isTueOfOpexWeek()
    inVanna := false

if inWeakness and endWeakNextTue and (dayofweek == dayofweek.tuesday) and not f_isOpexWeek()
    inWeakness := false

Overview

Expiration Highlights: Opex, Quarterly Opex & VIX with Vanna/Charm calculates monthly OpEx (the third Friday of each month), quarterly OpEx (March, June, September, December), and corresponding VIX expiration dates, drawing vertical lines to mark each event. It also highlights temporal trading windows such as pre-OpEx Vanna and Charm flows and post-OpEx weakness periods using colored background fills. Settings allow toggling specific expiration markers and adjusting the duration of the flow windows.

Details

Published by

namuan on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Sessions & time

Markets

Indices, Stocks

Timeframes

M15-H1, H4 and above

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

trading-strategiesmarket-analysisdtalestock-market-analysistelegram-botearnings-calendaroptions-trading

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Show monthly opex linesbooltrueshowOpexLines
Show quarterly opex linesbooltrueshowQuarterly
Show VIX expiration linesbooltrueshowVIXLines
Vanna/Charm start (days before opex)int11vannaStartDays
End vanna/charm on Tue of opex weekbooltrueendVannaOnTue
Start weakness on Wed of opex weekbooltruestartWeakOnWed
End weakness on Tue after opexbooltrueendWeakNextTue
Opex line colorcolorcolor.new(color.blue, 10)colOpex
Quarterly opex line colorcolorcolor.new(color.purple, 10)colQuarter
VIX line colorcolorcolor.new(color.orange, 10)colVIX
Vanna/Charm fillcolorcolor.new(color.green, 85)colVanna
Weakness fillcolorcolor.new(color.red, 85)colWeak
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

948 stars

This indicator counts down to a fixed Litecoin halving timestamp in August 2019, using Greenwich Mean Time. It subtracts the current time from that stamp and formats the remaining days, hours, minutes, and seconds. The day, hour, and minute of the target are u

Indicator v4 Sessions & time
Updated 10 days ago · GPL-3.0 GitHub repository of Litecoin Halving UTC Countdown
575 stars

This indicator builds Market Profile Time Price Opportunity (TPO) structures across defined session timeframes directly on the main price chart. It visualizes the Point of Control (POC) and Value Area boundaries using dynamic box drawings. An integrated multi-

Indicator v5 Support & resistanceScreeners & dashboards
Updated 1 year ago · MPL-2.0 GitHub repository of Market Profile with Screener
257 stars

This indicator plots auto trade signals for E-mini S&P 500 futures on the price chart. It computes an EMA200 filter along with day ETH RTH session levels and percentage-based entry zones. Signals trigger CALL or PUT cases when price crosses defined thresholds

Indicator v6 TrendSupport & resistance
Updated 6 weeks ago · None stated GitHub repository of Auto Trade Futures ES
219 stars

This indicator plots reference levels for previous daily high and low prices directly on the price chart. It requests daily timeframe data using the security function and plots the offset values as continuous lines, displaying resistance in red and support in

Indicator v4 Support & resistanceSessions & time
Updated 5 years ago · None stated GitHub repository of 昨日高低點標示

Golden Bullet Strategy

by TradersPost
218 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy

Moon Dev GEX Arrows

by moondevonyt
92 stars

This overlay indicator plots option strike walls and an optional session VWAP on the price chart for SPY or ES. It spaces major strikes by the selected instrument, draws a set number of strikes on each side, and marks wall-trap and sweep events after a cooldow

Indicator v5 Support & resistanceSessions & time
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev GEX Arrows

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers