// Super Trend inverso (& channel)
//
//Multiplier = 3
//Periods = 10
Multiplier = Max(1,Min(999,Multiplier))
Periods = Max(1,Min(999,Periods))
IF BarIndex > Max(Periods,Multiplier) THEN
MyATR = AverageTrueRange[Periods](close) * Multiplier
BasicUPPER = MedianPrice + MyATR
BasicLOWER = MedianPrice - MyATR
IF (BasicUPPER < FinalUPPER[1]) OR (close[1] > FinalUPPER[1]) THEN
FinalUPPER = BasicUPPER
ENDIF
IF (BasicLOWER > FinalLOWER[1]) OR (close[1] < FinalLOWER[1]) THEN
FinalLOWER = BasicLOWER
ENDIF
IF (ST[1] = FinalUPPER[1]) AND (close <= FinalUPPER) THEN
ST = FinalUPPER
SX = FinalLOWER
ELSE
IF (ST[1] = FinalUPPER[1]) AND (close > FinalUPPER) THEN
ST = FinalLOWER
SX = FinalUPPER
ELSE
IF (ST[1] = FinalLOWER[1]) AND (close >= FinalLOWER) THEN
ST = FinalLOWER
SX = FinalUPPER
ELSE
IF (ST[1] = FinalLOWER[1]) AND (close < FinalLOWER) THEN
ST = FinalUPPER
SX = FinalLOWER
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
RETURN ST AS "Super Trend",SX AS "Super Trend inverted"