1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
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.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Show monthly opex lines
bool
true
showOpexLines
Show quarterly opex lines
bool
true
showQuarterly
Show VIX expiration lines
bool
true
showVIXLines
Vanna/Charm start (days before opex)
int
11
vannaStartDays
End vanna/charm on Tue of opex week
bool
true
endVannaOnTue
Start weakness on Wed of opex week
bool
true
startWeakOnWed
End weakness on Tue after opex
bool
true
endWeakNextTue
Opex line color
color
color.new(color.blue, 10)
colOpex
Quarterly opex line color
color
color.new(color.purple, 10)
colQuarter
VIX line color
color
color.new(color.orange, 10)
colVIX
Vanna/Charm fill
color
color.new(color.green, 85)
colVanna
Weakness fill
color
color.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.
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
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-
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
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
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
Indicatorv6SMC / ICT / price actionSessions & time
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