Moving Average Crossover RSI Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
This script plot the 5 SMA (Simple Moving Average) of the RSI (Relative Strength Index) inside the default RSI indicator.

If you're looking for ThansonStevens' RSI/MA5 crossover indicator that he mentioned via his Twitter page, click here.


thinkScript Code

Rich (BB code):
#
# TD Ameritrade IP Company, Inc. (c) 2007-2019
# Tweaked by @korygill
# https://usethinkscript.com/d/185-moving-average-crossover-rsi-indicator-for-thinkorswim

declare lower;

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;
input rsiMALength = 5; #hint rsiMALength: RSI Moving Average Length
input rsiAverageType = AverageType.SIMPLE;

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;

plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;

# plot the RSI Moving Average
def rsiMA = MovingAverage(rsiAverageType, RSI, rsiMALength);
plot prsiMA = rsiMA;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.color("OverBought") else if RSI < over_Sold then RSI.color("OverSold") else RSI.color("Normal"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

Shareable Link

http://tos.mx/ldVZ7s

Credit:
  • @korygill
 
Last edited:
korygill

korygill

New member
VIP
If there is a strategy or some signals for this, we can add them to the code here and update.

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@korygill The strategy is MA5 crossing above the RSI for long and MA5 crossing down the RSI for short.

 
Last edited:
korygill

korygill

New member
VIP
The code above is not Thanson's strategy or how these two indicators draw on TradingView. I did not know about that when I was asked about adding a moving average to the RSI. I will look into fixing this and post an update.

 
Last edited:

Top