On a 1 hour chart, can someone help with s code that at 9am in today’s trading session, looks at yesterday’s trading session and draws horizontal lines on highest high and lowest low between 10am and 12 noon. It should keep those lines across all of today’s trading session and only resets and does same again once today’s session is over and chart gets to tomorrow’s session at 9am
Hi. Test this code:
sessionStart = 090000 // 09:00:00
rangeStart = 100000 // 10:00:00
rangeEnd = 120000 // 12:00:00
if opentime=sessionStart then
bar=barindex
endif
once maxref=high
once minref=low
if opentime>=rangeStart and opentime[1]<rangeStart then
lastmaxref=maxref
lastminref=minref
maxref=high
minref=low
elsif opentime>=rangeStart and opentime<=rangeEnd then
maxref=max(high,maxref)
minref=min(minref,low)
endif
if islastbarupdate then
drawsegment(bar,lastmaxref,barindex+5,lastmaxref)coloured("cyan")
drawsegment(bar,lastminref,barindex+5,lastminref)coloured("red")
endif
return minref coloured("red",75), maxref coloured("cyan",75)
Thank you Ivan. It works.
How do I now add to exactly same i.e. highest high and lowest low between 12noon and 2pm and between 2pm and 4pm?
In other words when I run the code, every morning at 9am, it draws 3 pairs of high and lows, 1 pair 10 to 12 of previous session, 1 pair between 12 and 2 previous session and 1 pair between 2 and 4pm of last session.
tnx in advnce
Hi. You introduce as much intervals as you want. Here one more (Just do the same)
// Horarios configurables
sessionStart = 090000 // 09:00:00
rangeStart = 100000 // 10:00:00
rangeEnd = 120000 // 12:00:00
rangeStart1 = 220000
rangeEnd1 = 020000
if opentime=sessionStart then
bar=barindex
endif
once maxref=high
once minref=low
once maxref1=high
once minref1=low
if opentime>=rangeStart and opentime[1]<rangeStart then
lastmaxref=maxref
lastminref=minref
maxref=high
minref=low
elsif opentime>=rangeStart and opentime<=rangeEnd then
maxref=max(high,maxref)
minref=min(minref,low)
endif
if opentime>=rangeStart1 and opentime[1]<rangeStart1 then
lastmaxref1=maxref1
lastminref1=minref1
maxref1=high
minref1=low
elsif opentime>=rangeStart1 and opentime<=rangeEnd1 then
maxref1=max(high,maxref1)
minref1=min(minref1,low)
endif
if islastbarupdate then
drawsegment(bar,lastmaxref,barindex+5,lastmaxref)coloured("cyan")
drawsegment(bar,lastminref,barindex+5,lastminref)coloured("red")
drawsegment(bar,lastmaxref1,barindex+5,lastmaxref1)coloured("blue")
drawsegment(bar,lastminref1,barindex+5,lastminref1)coloured("fuchsia")
endif
return minref1 coloured("fuchsia",75), maxref1 coloured("blue",75),minref coloured("red",75), maxref coloured("cyan",75)