TIMEFRAME (5 MINUTES)
NrBarra = BarIndex
//Chiusura e apertura barra Heikin-Ashi
Once Open5 = Open
IF BarIndex > 4 THEN
Close5 = TotalPrice
Open5 = (Open5[1] + Close5[1]) / 2
ENDIF
//Chiusura e apertura della precedente candela Heikin-Ashi
IF BarIndex > 4 THEN
PrevClose5 = TotalPrice[1]
PrevOpen5 = (PrevOpen5[2] + PrevClose5[2]) / 2
ENDIF
//-------------------------------------------------------------------
//direzione del trend - bottom/top waves
EndUp = 0
EndDown = 0
//Inverssione
IF (Close5 > Open5) AND (PrevClose5 < PrevOpen5) THEN
StartUp = NrBarra
EndDown = NrBarra
ELSIF (Close5 < Open5) AND (PrevClose5 > PrevOpen5) THEN
EndUp = NrBarra
StartDown = NrBarra
ENDIF
//Nuovo TOP
IF EndUp > StartUp THEN
LOnda = EndUp-StartUp+1
NewTop = highest[LOnda]
DrawArrowDown(NrBarra,NewTop)
ENDIF
IF NewTop > MemNewTop THEN
MemNewTop = NewTop
ENDIF
//Nuovo bottom
IF EndDown > StartDown THEN
LOnda = EndDown-StartDown+1
NewBottom = lowest[LOnda]
DrawArrowUp(NrBarra,NewBottom)
ENDIF
IF NewBottom > MemNewBottom THEN
MemNewBottom = NewBottom
ENDIF
Return NewTop Coloured ("Green"), NewBottom Coloured ("Red")