traderstu22

TS_OpeningRange_IB_V1

57
Code mostly borrowed from Chris Moody, nothing new here, just customized for myself.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

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.

Want to use this script on a chart?
study(title="TS_OpeningRange_IB_V1", shorttitle="TS_OpeningRange_IB_V1", overlay=true)

up60on = input(true, title="60 Minute Opening Range High")
down60on = input(true, title="60 Minute Opening Range Low")
res = input('60', type=resolution, title=" length/time Of Opening Range?")

sessToUse='0930-1600'
bartimeSess = time('D', sessToUse)
fr2to17 = time(period, sessToUse)

is_newbar(res) => change(time(res, sessToUse)) != 0 
adopt(r, s) => security(tickerid, r, s) 

high_range = valuewhen(is_newbar('D'),high,0)
low_range = valuewhen(is_newbar('D'),low,0)

highColor =time ("1", sessToUse)?yellow:na 
lowColor =time ("1", sessToUse)?yellow:na 

up = plot((fr2to17>0 and up60on) ? adopt(res, high_range): na, color = highColor, style=circles, linewidth=2) 
down = plot((fr2to17>0 and down60on) ? adopt(res, low_range): na, color = lowColor, style=circles, linewidth=2) 

fill(up, down, color = white, transp=85)