Multiplier = 3
Periods = 10
/ candele HA
ONCE xOpen = open
xClose = (open + high + low + close) / 4
IF BarIndex > 1 THEN
xOpen = (xOpen[1] + xClose[1]) / 2
ENDIF
xLow = min(low,min(xClose,xOpen))
xHigh = max(high,max(xClose,xOpen))
MedianHA = (xHigh + xLow) / 2
//
IF BarIndex > Max(Periods,Multiplier) THEN
MyATR = AverageTrueRange[Periods](xClose) * Multiplier
BasicUPPER = MedianHA + MyATR
BasicLOWER = MedianHA - MyATR
IF (BasicUPPER < FinalUPPER[1]) OR (xClose[1] > FinalUPPER[1]) THEN
FinalUPPER = BasicUPPER
ENDIF
IF (BasicLOWER > FinalLOWER[1]) OR (xClose[1] < FinalLOWER[1]) THEN
FinalLOWER = BasicLOWER
ENDIF
IF (ST[1] = FinalUPPER[1]) AND (xClose <= FinalUPPER) THEN
ST = FinalUPPER
ELSE
IF (ST[1] = FinalUPPER[1]) AND (xClose > FinalUPPER) THEN
ST = FinalLOWER
ELSE
IF (ST[1] = FinalLOWER[1]) AND (xClose >= FinalLOWER) THEN
ST = FinalLOWER
ELSE
IF (ST[1] = FinalLOWER[1]) AND (xClose < FinalLOWER) THEN
ST = FinalUPPER
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
RETURN ST AS "Super Trend HA"