OPEN-SOURCE SCRIPT
SPX +10 / -10 From 9:30 Open

//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)
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)
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.