DEFPARAM DrawOnLastBarOnly = true
ONCE r = 0
ONCE g = 0
ONCE b = 0
ONCE t = 255
ONCE p = 0
ONCE N = 0
psar = SAR[0.02,0.02,0.2]
A = ABS(psar - psar[1])
IF psar > close then
if psar[1] < close[1]THEN
Distancia = 0
N = 0
p = 0
ELSE
Distancia = max(Distancia, A)
IF (Distancia > Distancia[1]) AND (Distancia[1] <> 0) THEN
N = N + 1
$myBAR[N] = BarIndex
$myPSAR[N] = PSAR + 30
p = 1
ENDIF
ENDIF
elsif psar < close then
if psar[1] > close[1]THEN
Distancia = 0
N = 0
p = 0
ELSE
Distancia = max(Distancia, A)
IF (Distancia > Distancia[1]) AND (Distancia[1] <> 0) THEN
N = N + 1
$myBAR[N] = BarIndex
$myPSAR[N] = PSAR - 30
p = -1
ENDIF
ENDIF
ENDIF
IF N > 0 THEN
IF p > 0 THEN
r = 255
g = 0
FOR i = 1 TO N
x1 = $myBAR[i]
x2 = $myPSAR[i]
x3 = x2 + 30
DrawText("↓",x1,x2,dialog,bold,30) coloured(r,g,b,t)
DrawText("#A#",x1,x3+30,dialog,bold,10) //coloured(r,g,b,t)
NEXT
ELSIF p < 0 THEN
r = 0
g = 255
FOR i = 1 TO N
x1 = $myBAR[i]
x2 = $myPSAR[i]
x3 = x2 - 30
DrawText("↑",x1,x2,dialog,bold,30) coloured(r,g,b,t)
DrawText("#A#",x1,x3-30,dialog,bold,10) //coloured(r,g,b,t)
NEXT
ENDIF
ENDIF
RETURN psar AS "Sar"