OPEN-SOURCE SCRIPT

SPX +10 / -10 From 9:30 Open

22
//version=5
indicator("SPX +10 / -10 From 9:30 Open", overlay=true)

// Exchange Time (New York)
sess = input.session("0930-1600", "Regular Session (ET)")

// Detect session and 9:30 AM bar
inSession = time(timeframe.period, sess)

// Capture the 9:30 AM open
var float open930 = na

if inSession
// If this is the first bar of the session (9:30 AM)
if time(timeframe.period, sess)[1] == na
open930 := open
else
open930 := na

// Calculate movement from 9:30 AM open
up10 = close >= open930 + 10
dn10 = close <= open930 - 10

// Plot reference lines
plot(open930, "9:30 AM Open", color=color.orange)
plot(open930 + 10, "+10 Level", color=color.green)
plot(open930 - 10, "-10 Level", color=color.red)

// Alert conditions
alertcondition(up10, title="SPX Up +10", message="SPX moved UP +10 from the 9:30 AM open")
alertcondition(dn10, title="SPX Down -10", message="SPX moved DOWN -10 from the 9:30 AM open")

// Plot signals on chart
plotshape(up10, title="+10 Hit", style=shape.labelup, color=color.green, text="+10", location=location.belowbar, size=size.tiny)
plotshape(dn10, title="-10 Hit", style=shape.labeldown, color=color.red, text="-10", location=location.abovebar, size=size.tiny)

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.