defparam calculateonlastbars = 1000
defparam drawonlastbaronly = true
ONCE Massimo = 0
PeriodiStorico = 100 //100
Massimo = highest[PeriodiStorico](high)
IF Massimo <> Massimo[1] THEN
Barra15 = 0
Barra30 = 0
ENDIF
Ritracciamento15 = Massimo * 0.85
Ritracciamento30 = Massimo * 0.70
FOR Barra = 0 TO PeriodiStorico - 1
IF Massimo = high[Barra] THEN
DistanzaFreccia = high[Barra] + range[Barra]
Break
ENDIF
NEXT
IF low CROSSES UNDER Ritracciamento30 THEN
Barra30 = BarIndex
Dist30 = low - range*1.5
ENDIF
IF low CROSSES UNDER Ritracciamento15 THEN
Barra15 = BarIndex
Dist15 = low - range
ENDIF
BarraMax = BarIndex[Barra]
DRAWHLINE(Massimo) coloured(0,255,0,255) //Linea VERDE (Massimo)
DRAWHLINE(Ritracciamento15) coloured(0,0,255,255) //Linea BLU (ritracciamento 15%)
DRAWHLINE(Ritracciamento30) coloured(255,0,0,255) //Linea ROSSA (ritracciamento 30%)
DRAWARROWDOWN(BarraMax,DistanzaFreccia) coloured(255,0,0,255) //Freccia ROSSA sul massimo
IF Barra15 > 0 THEN
DRAWARROWUP(Barra15,Dist15) coloured(0,128,0,255) //Freccia VERDE sotto il 15%
ENDIF
IF Barra30 > 0 THEN
DRAWARROWUP(Barra30,Dist30) coloured(0,255,0,255) //Freccia VERDE sotto il 30%
ENDIF
RETURN