hello fellow traders, seeking help with basic coding,,,
i am trying to get the candles to change red(BEARISH) when rsi is below 50line bullish(green) when above 50 line candles change to (cyan)when overbought70
change to yellow when oversold30
i have started to code below which is partially successful however it doesnt seem to change colors when above70 or below30, it is only changing green/red when above or below the 50 line,,
please see code below
declare upper;
input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;
input ColoredCandlesOn = yes;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def OverSold = 70;
def OverBought = 30;
def UP = RSI > 50;
def DN = RSI < 50;
def UpCalc = UP - DN;
AssignPriceColor (if UP then Color.GREEN else if DN then Color.RED else if OverBought then Color.CYAN else if OverSold then Color.YELLOW
else Color.CURRENT
);
i am trying to get the candles to change red(BEARISH) when rsi is below 50line bullish(green) when above 50 line candles change to (cyan)when overbought70
change to yellow when oversold30
i have started to code below which is partially successful however it doesnt seem to change colors when above70 or below30, it is only changing green/red when above or below the 50 line,,
please see code below
declare upper;
input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;
input ColoredCandlesOn = yes;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def OverSold = 70;
def OverBought = 30;
def UP = RSI > 50;
def DN = RSI < 50;
def UpCalc = UP - DN;
AssignPriceColor (if UP then Color.GREEN else if DN then Color.RED else if OverBought then Color.CYAN else if OverSold then Color.YELLOW
else Color.CURRENT
);