//past values stored for testing
$res[0]=16648
$res[1]=16787.7
$res[2]=16960.2
$res[3]=17003.9
$res[4]=16443.6
$res[5]=16390.6
$res[6]=16250
$res[7]=15987.8
$res[8]=15913
$res[9]=15880.7
$res[10]=15701.4
$res[11]=15638.9
$res[12]=15480.9
$res[13]=15333
$res[14]=15236.7
$res[15]=15170.1
$res[16]=15075
$res[17]=15048.9
$res[18]=14990.1
$res[19]=14928.9
$res[20]=14785.4
$res[21]=14691.5
$res[22]=14633.1
$res[23]=14589.2
$res[24]=14460
$sup[0]=16648
$sup[1]=16787.7
$sup[2]=16960.2
$sup[3]=17003.9
$sup[4]=16443.6
$sup[5]=16390.6
$sup[6]=16250
$sup[7]=15987.8
$sup[8]=15913
$sup[9]=15880.7
$sup[10]=15701.4
$sup[11]=15638.9
$sup[12]=15480.9
$sup[13]=15333
$sup[14]=15236.7
$sup[15]=15170.1
$sup[16]=15075
$sup[17]=15048.9
$sup[18]=14990.1
$sup[19]=14928.9
$sup[20]=14785.4
$sup[21]=14691.5
$sup[22]=14633.1
$sup[23]=14589.2
$sup[24]=14460
//periode is defined as 24hours or 97 quarter-hour candles
period = 97
ONCE myindexres=25
ONCE myindexsup=25
//10PM is when we fill and filter the arrays
if time=220000 Then
//add highest and lowest since yesterday 10PM and draw them as lines
$res[myindexres] = highest[period](high)
DRAWHLINE($res[myindexres]) COLOURED ("RED")
$sup[myindexsup] = lowest[period](low)
DRAWHLINE($sup[myindexsup]) COLOURED ("BLUE")
//reset all past resistance values that are engulfed by the last 24h highest and lowest
FOR a=0 to myindexres-1 DO
IF $res[a]<$res[myindexres] AND $res[a]>$sup[myindexsup] THEN
$res[a]=0
CONTINUE
ENDIF
//only draw the resistance lines when they are not engulfed
IF IsSet($res[a])=1 THEN
DRAWHLINE($res[a]) COLOURED ("ORANGE") STYLE (Dottedline1)
CONTINUE
ENDIF
NEXT
//reset all past support values that are engulfed by the last 24h highest and lowest
FOR a=0 to myindexsup-1 DO
IF $sup[a]<$res[myindexres] AND $sup[a]>$sup[myindexsup] THEN
$sup[a]=0
CONTINUE
ENDIF
//only draw the resistance lines when they are not engulfed
IF IsSet($sup[a])=1 THEN
DRAWHLINE($sup[a]) COLOURED ("CYAN") STYLE (Dottedline2)
CONTINUE
ENDIF
NEXT
//reset the index count for the next day
IF IsSet($res[myindexres])=1 THEN
myindexres=myindexres+1
ENDIF
IF IsSet($sup[myindexsup])=1 THEN
myindexsup=myindexsup+1
endif
ENDIF
RETURN