Hi jtsas!
Achieving that is kind of tricky and will require the use of "var" variables.
What you need to do is something like this:
Step 1: Detect when your session begins or ends
Code: Select all
// InSession() determines if a price bar falls inside the specified session
InSession(sess) => na(time(timeframe.period, sess)) == false
Step 2: Detect the high / low of the session
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
Step 3: Reset high/low when the session ends
Code: Select all
if not InSession(<specified_trading_session>)
highOfSession := na
lowOfSession := na
Step 4: Draw/fill background
Code: Select all
highPlot = plot(highOfSession)
lowPlot = plot(lowOfSession)
fill(highPlot, lowPlot, color=color.yellow)
Unfortunately I don't have time to go into more detail, this is just some pseudo-code to get you thinking about potential solutions. This kind of thing is fairly complex and is something we'll cover in the Mentorship Program when it's released :) best of luck with your trading!