Code: Select all
// InSession() determines if a price bar falls inside the specified session
InSession(sess) => na(time(timeframe.period, sess)) == false
Code: Select all
var highOfSession = 0.0
var lowOfSession = 99999999
if InSession(<specified_trading_session>) and (high > highOfSession or na(highOfSession))
highOfSession := high
if InSession(<specified_trading_session>) and (low < lowOfSession or na(lowOfSession))
lowOfSession := low
Code: Select all
if not InSession(<specified_trading_session>)
highOfSession := na
lowOfSession := na
Code: Select all
highPlot = plot(highOfSession)
lowPlot = plot(lowOfSession)
fill(highPlot, lowPlot, color=color.yellow)