This is a triple smoothed RSI designed to show smoother and clearer oscillator swings compared to other RSI or momentum studies.
Code:
# Derivative RSI Oscillator
# Can be used alone as a smoother RSI or as part of the Charting Wealth strategy when combined with the MACD and MAs Charting Wealth study.
# By Horserider 12/25/2019
#
declare lower;
input length = 14;
input length1 = 5;
input length2 = 3;
input length3 = 9;
input price = close;
def NetChgAvg = WildersAverage(price - price[1], length);
def TotChgAvg = WildersAverage(AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = (50 * (ChgRatio + 1) - 50);
#################################
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.YELLOW);
ZeroLine.SetLineWeight(1);
input averageType = AverageType.EXPONENTIAL;
input averageType2 = averageType.SIMPLE;
def x = MovingAverage(averageType,RSI, length1);
def x2 = MovingAverage(averageType, x, length2);
def xs = MovingAverage(averageType2, x2 , length3);
def rsi__linediff = x2 - xs;
plot RSI_Line = rsi__linediff;
RSI_Line.SetDefaultColor(GetColor(1));
RSI_Line.SetDefaultColor(GetColor(5));
RSI_Line.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RSI_Line.SetLineWeight(3);
RSI_Line.DefineColor("Positive and Up", Color.GREEN);
RSI_Line.DefineColor("Positive and Down", Color.DARK_GREEN);
RSI_Line.DefineColor("Negative and Down", Color.RED);
RSI_Line.DefineColor("Negative and Up", Color.DARK_RED);
RSI_Line.AssignValueColor(if RSI_Line >= 0 then if RSI_Line > RSI_Line[1] then RSI_Line.color("Positive and Up") else RSI_Line.color("Positive and Down") else if RSI_Line < RSI_Line[1] then RSI_Line.color("Negative and Down") else RSI_Line.color("Negative and Up"));
Last edited: