This indicator is a simple modification of the popular RSI, set to 2 periods and using a farther back price value to smooth out much of the chop in the RSI plot. It's been quite helpful to point out dip areas in uptrending stocks; I've yet to find a way to use it on the short side.
Code:
# Smoothed RSI2
# Pensar
# Created early 2020
# Released 05.18.2021 - V.1.0
# This indicator is an simple variation of the Connors 2-period RSI.
# It uses the third price value back to smooth the RSI plot.
declare lower;
input period = 2;
input over_bought = 90;
input over_sold = 10;
input idata = close;
input averageType = AverageType.WILDERS;
def NetChgAvg = MovingAverage(averageType, idata - idata[3], period);
def TotChgAvg = MovingAverage(averageType, AbsValue(idata - idata[3]), period);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
plot RSI = 50 * (ChgRatio + 1);
RSI.DefineColor("OverBought", color.red);
RSI.DefineColor("Normal", color.gray);
RSI.DefineColor("OverSold", color.green);
RSI.AssignValueColor(if RSI > over_Bought then RSI.color("OverBought")
else if RSI < over_Sold then RSI.color("OverSold")
else RSI.color("Normal"));
plot OverSold = over_Sold;
plot OverBought = over_Bought;
OverSold.SetDefaultColor(color.green);
Oversold.setstyle(curve.short_dash);
Oversold.setlineweight(1);
OverBought.SetDefaultColor(color.red);
OverBought.setstyle(curve.short_dash);
Oversold.setlineweight(1);
AddCloud(if RSI > OverBought then RSI else double.nan, Overbought, color.red,color.red);
AddCloud(if RSI < OverSold then RSI else double.nan, OverSold, color.green,color.green);
# End Code