Para dibujar las flechas en las ultimas 4 velas (y los valores solo en la ultima), aqui esta:
defparam drawonlastbaronly=true
FL1=0
FL2=0
FL3=0
N=4 // number of candles (including current one) you want your arrows displayed on
psar = SAR[0.02,0.02,0.2]
A = ABS(psar - psar[1])
B= ABS(A-A[1])
Distancia = psar - psar[1]
IF psar > close then
if psar[1] < close[1]THEN
Distancia = 0
ELSE
IF (Distancia > Distancia[1]) AND (Distancia[1] <> 0) THEN
ENDIF
ENDIF
DrawText("#A#",BarIndex[0],Offset,dialog,bold,14)
elsif psar < close then
if psar[1] > close[1]THEN
Distancia = 0
ELSE
IF (Distancia > Distancia[1]) AND (Distancia[1] <> 0) THEN
ENDIF
ENDIF
DrawText("#A#",BarIndex[0],Offset,dialog,bold,14)
ENDIF
Offset = psar - (average[100,0](range) / 3)
IF close <= psar THEN
Offset = psar + (average[100,0](range) / 3)
endif
iF psar > close then
DRAWTEXT(psar, barindex,PSAR+16)
else
DRAWTEXT(psar, barindex,PSAR-16)
endif
C1= CLOSE => PSAR
C2= CLOSE <= PSAR
CONTADOR = 0
IF distancia => distancia[1] AND C1 THEN
CONTADOR = 1 + CONTADOR[1]
PE = HIGHEST [CONTADOR+1](HIGH)
//DrawText("↓",BarIndex[0],Offset,dialog,bold,30) coloured("Red",255)
FL1=1
ENDIF
CUENTA = 0
IF distancia <= distancia[1] AND C2 THEN
CUENTA = 1+ CUENTA [1]
PE = LOWEST[CUENTA+1] (LOW)
//DrawText("↓",BarIndex[0],Offset,dialog,bold,30) coloured("Red",255)
FL2=1
ENDIF
IF C2 AND CLOSE > PSAR THEN
CUENTA = 1+ CUENTA [1]
PE = LOWEST[CUENTA+1] (LOW)
//DrawText("↓",BarIndex[0],Offset,dialog,bold,30) coloured("Red",255)
FL3=1
ENDIF
for i=0 to N-1
if FL1[i] or FL2[i] or FL3[i] then
DrawText("↓",BarIndex[i],Offset[i],dialog,bold,30) coloured("Red",255)
endif
next
RETURN a as "distancia"