RicardoSantos

[RS]Session Pivot V0

request for Robski.
Pivots starting at 8am gmt
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?
//@version=2
study(title='[RS]Session Pivot V0', shorttitle='SP', overlay=true)
session_time = input(title='Session time:', type=string, defval='0300-1500')
isinsession = not na(time('1', session_time))
isnewsession = change(isinsession)>0

session_open = isnewsession ? open : session_open[1]
session_high = na(session_high[1]) ? high :isnewsession ? high : high >= session_high[1] ? high : session_high[1]
session_low = na(session_low[1]) ? low :isnewsession ? low : low <= session_low[1] ? low : session_low[1]

//plot(session_open, color=gray)
//plot(session_high, color=gray)
//plot(session_low, color=gray)

P = isnewsession ? (session_high[1] + session_low[1] + session_open) / 3 : P[1]
S1 = isnewsession ? (P * 2) - session_high[1] : S1[1]
S2 = isnewsession ? P - (session_high[1]-session_low[1]) : S2[1]
R1 = isnewsession ? (P * 2) - session_low[1] : R1[1]
R2 = isnewsession ? P + (session_high[1]-session_low[1]) : R2[1]

plot(title='P', series=P, color=isnewsession?na:black)
plot(title='S1', series=S1, color=isnewsession?na:black)
plot(title='S2', series=S2, color=isnewsession?na:black)
plot(title='R1', series=R1, color=isnewsession?na:black)
plot(title='R2', series=R2, color=isnewsession?na:black)