Monthly Options Expiration 2022
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © imzeeshan
// Source: https://www.marketwatch.com/optionscenter/calendar/2022

//@version=5
indicator("Monthly Options Expiration 2022", overlay=true)

expiry=year==2021 and month==11 and dayofmonth==19 and timeframe.isdaily
c=input('F', title="Character")
o=input(7, title="X bars before")

jan=42
feb=jan+20+0
mar=feb+20-1
apr=mar+20-1
may=apr+20+5
jun=may+20-1
jul=jun+20-2
aug=jul+20+5
sep=aug+20-1
oct=sep+20+5
nov=oct+20+0
dec=nov+20-1
// Expirations
plotchar(expiry, title="Jan", char=c, location = location.bottom, color=color.blue, offset=jan, editable=false)
plotchar(expiry, title="Feb", char=c, location = location.bottom, color=color.blue, offset=feb, editable=false)
plotchar(expiry, title="Mar", char=c, location = location.bottom, color=color.blue, offset=mar, editable=false)
plotchar(expiry, title="Apr", char=c, location = location.bottom, color=color.blue, offset=apr, editable=false)
plotchar(expiry, title="May", char=c, location = location.bottom, color=color.blue, offset=may, editable=false)
plotchar(expiry, title="Jun", char=c, location = location.bottom, color=color.blue, offset=jun, editable=false)
plotchar(expiry, title="Jul", char=c, location = location.bottom, color=color.blue, offset=jul, editable=false)
plotchar(expiry, title="Aug", char=c, location = location.bottom, color=color.blue, offset=aug, editable=false)
plotchar(expiry, title="Sep", char=c, location = location.bottom, color=color.blue, offset=sep, editable=false)
plotchar(expiry, title="Oct", char=c, location = location.bottom, color=color.blue, offset=oct, editable=false)
plotchar(expiry, title="Nov", char=c, location = location.bottom, color=color.blue, offset=nov, editable=false)
plotchar(expiry, title="Dec", char=c, location = location.bottom, color=color.blue, offset=dec, editable=false)

// Last week of expirations 
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=jan-o, editable=false)
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=feb-o, editable=false)
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=mar-o, editable=false)
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=apr-o, editable=false)
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=may-o, editable=false)
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=jun-o, editable=false)
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=jul-o, editable=false)
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=aug-o, editable=false)
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=sep-o, editable=false)
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=oct-o, editable=false)
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=nov-o, editable=false)
plotshape(expiry, style=shape.flag, location = location.bottom, color=color.blue, offset=dec-o, editable=false)

// Start of month
show_som=input(true, title="Start of month")
som = show_som and year==2022 and month!=month[1]
plotshape(som, style=shape.circle, location = location.bottom, color=color.blue, editable=false)