Just for fun here is a version that draws the last ten days highs and lows.
once $hday[1] = undefined
once $hday[2] = undefined
once $hday[3] = undefined
once $hday[4] = undefined
once $hday[5] = undefined
once $hday[6] = undefined
once $hday[7] = undefined
once $hday[8] = undefined
once $hday[9] = undefined
once $hday[10] = undefined
once $lday[1] = undefined
once $lday[2] = undefined
once $lday[3] = undefined
once $lday[4] = undefined
once $lday[5] = undefined
once $lday[6] = undefined
once $lday[7] = undefined
once $lday[8] = undefined
once $lday[9] = undefined
once $lday[10] = undefined
if intradaybarindex < intradaybarindex[1] then
a = a + 1
$dayhigh[a]=maxhigh
maxhigh = low
if a > 10 then
for b = 1 to 10
$hday[b] = $dayhigh[lastset($dayhigh)-b+1]
next
endif
c = c + 1
$daylow[c]=maxlow
maxlow = high
if c > 10 then
for b = 1 to 10
$lday[b] = $daylow[lastset($daylow)-b+1]
next
endif
endif
maxhigh = max(maxhigh,high)
maxlow = min(maxlow,low)
return $hday[1] coloured(0,128,0) as "day1",$hday[2] coloured(0,128,0) as "day2",$hday[3] coloured(0,128,0) as "day3",$hday[4] coloured(0,128,0) as "day4",$hday[5] coloured(0,128,0) as "day5",$hday[6] coloured(0,128,0) as "day6",$hday[7] coloured(0,128,0) as "day7",$hday[8] coloured(0,128,0) as "day8",$hday[9] coloured(0,128,0) as "day9",$hday[10] coloured(0,128,0) as "day10", $lday[1] coloured(128,0,0) as "day1",$lday[2] coloured(128,0,0) as "day2",$lday[3] coloured(128,0,0) as "day3",$lday[4] coloured(128,0,0) as "day4",$lday[5] coloured(128,0,0) as "day5",$lday[6] coloured(128,0,0) as "day6",$lday[7] coloured(128,0,0) as "day7",$lday[8] coloured(128,0,0) as "day8",$lday[9] coloured(128,0,0) as "day9",$lday[10] coloured(128,0,0) as "day10"