ark.analyst
New member
Hi, I am trying to modify Mobius supertrend indicator with EMA8 support. if paint the candles in GREEN, if mobius UP and close > ema 8, and candles RED, if Mobius DOWN with close < ema 8 , and others GRAY candles (NO ACTION).
See the code snippet below:
While applying the settings, I can see only GREEN and GRAY candles, but not RED.
Can someone help identify the error and point to me ?
See the code snippet below:
Code:
input AtrMult = 1.0;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1] then UP else DN;
plot SuperTrend = ST;
def ema8 = MovAvgExponential(8);
def Pos_State = close > ST and close > ema8;
def Neg_State = close < ST and close < ema8;
SuperTrend.AssignValueColor(if Pos_State then Color.GREEN
else if Neg_State then Color.RED
else Color.GRAY);
AssignPriceColor(if PaintBars and close < ST and close < ema8
then Color.RED
else if PaintBars and close > ST and close > ema8
then Color.GREEN
else Color.GRAY);
While applying the settings, I can see only GREEN and GRAY candles, but not RED.
Can someone help identify the error and point to me ?