Triple RSI For ThinkOrSwim

imauic90

New member
Just messing with a new RSI strategy. Using 3 RSI levels with a cross over to indicate going long or short. Just seeing if anyone can help me clean up the code a little better and plot the vertical lines when the parameter is truly met versus when the RSI levels are in transition. I'm fairly new to scripting and only know the basics.

V9AL8pT.png


Code:
###Triple RSI ###

declare lower;

input length = 8;
input length2 = 14;
input length3 = 21;
input over_Bought = 70;
input over_Sold = 30;
input over_Bought2 = 80;
input over_Sold2 = 20;
input over_Bought3 = 90;
input over_Sold3 = 10;
input midlineX = 50;


input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

###RSI ONE###
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;

###RSI TWO###
def NetChgAvg2 = MovingAverage(averageType, price - price[1], length2);
def TotChgAvg2 = MovingAverage(averageType, AbsValue(price - price[1]), length2);
def ChgRatio2 = if TotChgAvg2 != 0 then NetChgAvg2 / TotChgAvg2 else 0;

plot RSI2 = 50 * (ChgRatio2 + 1);
plot OverSold2 = over_Sold2;
plot OverBought2 = over_Bought2;

###RSI THREE###
def NetChgAvg3 = MovingAverage(averageType, price - price[1], length3);
def TotChgAvg3 = MovingAverage(averageType, AbsValue(price - price[1]), length3);
def ChgRatio3 = if TotChgAvg3 != 0 then NetChgAvg3 / TotChgAvg3 else 0;

plot RSI3 = 50 * (ChgRatio3 + 1);
plot OverSold3 = over_Sold3;
plot OverBought3 = over_Bought3;

###MIDLINE###

plot Midline = midlineX;


###Vertical Lines###

def M1 = RSI crosses above RSI2 and RSI3;
def M2 = M1+ M1[1];
AddVerticalLine(M2[0] > M2[1], "Go BULLISH!", Color.green, Curve.SHORT_DASH);

def M3 = RSI crosses below RSI2 and RSI3;
def M4 = M3+ M3[1];
AddVerticalLine(M4[0] > M4[1], "Go SHORT", Color.red, Curve.SHORT_DASH);
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Do anyone have or know how to make a lower study for Mutiple RSI. Also is there a way to level of rsi written out on a box?
5 Day RSI,
7 Day Rsi
14 Day Rsi
60 Day RSI
120 Day Rsi
 
@imauic90 How did u get the label " bearish volume" on your chart? Can you share the link? thank u


Code:
Volume###################################################################
#Colored Volume By Ethans080901
#Mod TroyX-8-17-18
#If today's closing price and volume is greater than 'n' days ago, color green
#If today's closing price is greater than 'n' days ago but volume is not, color blue
#If today's closing price is less than 'n' days ago, color orange
#If today's closing price is less than 'n' days ago but volume is not, color red

input n = 10;

def CN = Average(close, n);
def VN = Average(volume, n);
def G = close > CN and volume > VN ;
def B = close > CN and volume == VN;
def O = close < CN and volume == VN;
def R = close < CN and volume >= VN;

#Added volume Label
AddLabel( G, "Strong Bullish Volume" , Color.CYAN); #Strong Bull
AddLabel( B, "Weak Bullish Volume" , Color.blue); #Weak Bull
AddLabel( O, "Weak Bearish Volume" , Color.YELLOW); #Weak Bear
AddLabel( R, "Strong Bearish Volume" , Color.Dark_ORANGE); #Strong Bear

#How to use:
#Buy on Green or Blue
#Sell on Yellow or Orange

#End;
 
Just messing with a new RSI strategy. Using 3 RSI levels with a cross over to indicate going long or short. Just seeing if anyone can help me clean up the code a little better and plot the vertical lines when the parameter is truly met versus when the RSI levels are in transition. I'm fairly new to scripting and only know the basics.

V9AL8pT.png


Code:
###Triple RSI ###

declare lower;

input length = 8;
input length2 = 14;
input length3 = 21;
input over_Bought = 70;
input over_Sold = 30;
input over_Bought2 = 80;
input over_Sold2 = 20;
input over_Bought3 = 90;
input over_Sold3 = 10;
input midlineX = 50;


input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

###RSI ONE###
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;

###RSI TWO###
def NetChgAvg2 = MovingAverage(averageType, price - price[1], length2);
def TotChgAvg2 = MovingAverage(averageType, AbsValue(price - price[1]), length2);
def ChgRatio2 = if TotChgAvg2 != 0 then NetChgAvg2 / TotChgAvg2 else 0;

plot RSI2 = 50 * (ChgRatio2 + 1);
plot OverSold2 = over_Sold2;
plot OverBought2 = over_Bought2;

###RSI THREE###
def NetChgAvg3 = MovingAverage(averageType, price - price[1], length3);
def TotChgAvg3 = MovingAverage(averageType, AbsValue(price - price[1]), length3);
def ChgRatio3 = if TotChgAvg3 != 0 then NetChgAvg3 / TotChgAvg3 else 0;

plot RSI3 = 50 * (ChgRatio3 + 1);
plot OverSold3 = over_Sold3;
plot OverBought3 = over_Bought3;

###MIDLINE###

plot Midline = midlineX;


###Vertical Lines###

def M1 = RSI crosses above RSI2 and RSI3;
def M2 = M1+ M1[1];
AddVerticalLine(M2[0] > M2[1], "Go BULLISH!", Color.green, Curve.SHORT_DASH);

def M3 = RSI crosses below RSI2 and RSI3;
def M4 = M3+ M3[1];
AddVerticalLine(M4[0] > M4[1], "Go SHORT", Color.red, Curve.SHORT_DASH);
Hi, I found this very useful. Did you get a response? I am looking to find out how I can adjust the signal days "buy, sell" like calculating it a 2-3 days? Thanks in advance.
 
Can anyone script an RSI with 3 RSI bands settings at 5, 14, and 50? Thanks in advance.

this draws 3 RSI lines.
has color matched labels, to identify the lines.

Code:
# rsi_lines_00

declare lower;
input rsi1_len = 5;
input rsi2_len = 14;
input rsi3_len = 50;
def rsi1 = round(rsi(rsi1_len).rsi,2);
def rsi2 = round(rsi(rsi2_len).rsi,2);
def rsi3 = round(rsi(rsi3_len).rsi,2);

plot z1 = rsi1;
z1.SetDefaultColor(getcolor(1));
z1.hidebubble();

plot z2 = rsi2;
z2.SetDefaultColor(getcolor(2));
z2.hidebubble();

plot z3 = rsi3;
z3.SetDefaultColor(getcolor(3));
z3.hidebubble();

input show_labels = yes;
addlabel(show_labels, "RSI(" + rsi1_len + "): " + rsi1, z1.takevaluecolor());
addlabel(show_labels, "RSI(" + rsi2_len + "): " + rsi2, z2.takevaluecolor());
addlabel(show_labels, "RSI(" + rsi3_len + "): " + rsi3, z3.takevaluecolor());
#
 
#
# Charles Schwab & Co. (c) 2007-2025
#



input length = 7;
input over_Bought = 60;
input over_Sold = 40;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

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;

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);

#######################################



input length1 = 14;
input over_Bought1 = 60;
input over_Sold1 = 40;
input price1 = close;
input averageType1 = AverageType.WILDERS;
input showBreakoutSignals1 = no;

def NetChgAvg1 = MovingAverage(averageType1, price1 - price1[1], length1);
def TotChgAvg1 = MovingAverage(averageType1, AbsValue(price1 - price1[1]), length1);
def ChgRatio11 = if TotChgAvg1 != 0 then NetChgAvg1 / TotChgAvg1 else 0;

plot RSI1 = 50 * (ChgRatio11 + 1);
plot OverSold1 = over_Sold;
plot OverBought1 = over_Bought;
plot UpSignal1 = if RSI1 crosses above OverSold1 then RSI else Double.NaN;
plot DownSignal1 = if RSI1 crosses below OverBought1 then OverBought1 else Double.NaN;

UpSignal1.SetHiding(!showBreakoutSignals1);
DownSignal1.SetHiding(!showBreakoutSignals1);

RSI1.DefineColor("OverBought", GetColor(5));
RSI1.DefineColor("Normal", GetColor(7));
RSI1.DefineColor("OverSold", GetColor(1));
RSI1.AssignValueColor(if RSI1 > over_Bought1 then RSI1.Color("OverBought") else if RSI1 < over_Sold1 then RSI1.Color("OverSold") else RSI1.Color("Normal"));
OverSold1.SetDefaultColor(GetColor(8));
OverBought1.SetDefaultColor(GetColor(8));
UpSignal1.SetDefaultColor(Color.UPTICK);
UpSignal1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal1.SetDefaultColor(Color.DOWNTICK);
DownSignal1.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

##################################



input length2 = 21;
input over_Bought2 = 60;
input over_Sold2 = 40;
input price2 = close;
input averageType2 = AverageType.WILDERS;
input showBreakoutSignals2 = no;

def NetChgAvg2 = MovingAverage(averageType2, price2 - price1[1], length2);
def TotChgAvg2 = MovingAverage(averageType2, AbsValue(price1 - price2[1]), length2);
def ChgRatio12 = if TotChgAvg2 != 0 then NetChgAvg2 / TotChgAvg2 else 0;

plot RSI2 = 50 * (ChgRatio12 + 1);
plot OverSold2 = over_Sold;
plot OverBought2 = over_Bought;
plot UpSignal2 = if RSI2 crosses above OverSold2 then RSI2 else Double.NaN;
plot DownSignal2 = if RSI2 crosses below OverBought2 then OverBought2 else Double.NaN;

UpSignal2.SetHiding(!showBreakoutSignals2);
DownSignal2.SetHiding(!showBreakoutSignals2);

RSI2.DefineColor("OverBought", GetColor(5));
RSI2.DefineColor("Normal", GetColor(7));
RSI2.DefineColor("OverSold", GetColor(1));
RSI2.AssignValueColor(if RSI2 > over_Bought2 then RSI2.Color("OverBought") else if RSI2 < over_Sold2 then RSI2.Color("OverSold") else RSI2.Color("Normal"));
OverSold2.SetDefaultColor(GetColor(8));
OverBought2.SetDefaultColor(GetColor(8));
UpSignal2.SetDefaultColor(Color.UPTICK);
UpSignal2.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal2.SetDefaultColor(Color.DOWNTICK);
DownSignal2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

1741648801485.png


There might be some redundancy but it works.
 
I use 3 RSIs but differently. 9/14 and 2.

-crossing of 9/14 is very precise in general (I use daily charts mainly) for reversals though it needs help for confirmation to avoid false signals

-RSI9 as a trend indicator (levels 50 or otherwise 60/40 as thresholds, depending on purpose)

-and the RSI2 with Connors logic to check for extremes alerts
 
#
# Charles Schwab & Co. (c) 2007-2025
#



input length = 7;
input over_Bought = 60;
input over_Sold = 40;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;

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;

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);

#######################################



input length1 = 14;
input over_Bought1 = 60;
input over_Sold1 = 40;
input price1 = close;
input averageType1 = AverageType.WILDERS;
input showBreakoutSignals1 = no;

def NetChgAvg1 = MovingAverage(averageType1, price1 - price1[1], length1);
def TotChgAvg1 = MovingAverage(averageType1, AbsValue(price1 - price1[1]), length1);
def ChgRatio11 = if TotChgAvg1 != 0 then NetChgAvg1 / TotChgAvg1 else 0;

plot RSI1 = 50 * (ChgRatio11 + 1);
plot OverSold1 = over_Sold;
plot OverBought1 = over_Bought;
plot UpSignal1 = if RSI1 crosses above OverSold1 then RSI else Double.NaN;
plot DownSignal1 = if RSI1 crosses below OverBought1 then OverBought1 else Double.NaN;

UpSignal1.SetHiding(!showBreakoutSignals1);
DownSignal1.SetHiding(!showBreakoutSignals1);

RSI1.DefineColor("OverBought", GetColor(5));
RSI1.DefineColor("Normal", GetColor(7));
RSI1.DefineColor("OverSold", GetColor(1));
RSI1.AssignValueColor(if RSI1 > over_Bought1 then RSI1.Color("OverBought") else if RSI1 < over_Sold1 then RSI1.Color("OverSold") else RSI1.Color("Normal"));
OverSold1.SetDefaultColor(GetColor(8));
OverBought1.SetDefaultColor(GetColor(8));
UpSignal1.SetDefaultColor(Color.UPTICK);
UpSignal1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal1.SetDefaultColor(Color.DOWNTICK);
DownSignal1.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

##################################



input length2 = 21;
input over_Bought2 = 60;
input over_Sold2 = 40;
input price2 = close;
input averageType2 = AverageType.WILDERS;
input showBreakoutSignals2 = no;

def NetChgAvg2 = MovingAverage(averageType2, price2 - price1[1], length2);
def TotChgAvg2 = MovingAverage(averageType2, AbsValue(price1 - price2[1]), length2);
def ChgRatio12 = if TotChgAvg2 != 0 then NetChgAvg2 / TotChgAvg2 else 0;

plot RSI2 = 50 * (ChgRatio12 + 1);
plot OverSold2 = over_Sold;
plot OverBought2 = over_Bought;
plot UpSignal2 = if RSI2 crosses above OverSold2 then RSI2 else Double.NaN;
plot DownSignal2 = if RSI2 crosses below OverBought2 then OverBought2 else Double.NaN;

UpSignal2.SetHiding(!showBreakoutSignals2);
DownSignal2.SetHiding(!showBreakoutSignals2);

RSI2.DefineColor("OverBought", GetColor(5));
RSI2.DefineColor("Normal", GetColor(7));
RSI2.DefineColor("OverSold", GetColor(1));
RSI2.AssignValueColor(if RSI2 > over_Bought2 then RSI2.Color("OverBought") else if RSI2 < over_Sold2 then RSI2.Color("OverSold") else RSI2.Color("Normal"));
OverSold2.SetDefaultColor(GetColor(8));
OverBought2.SetDefaultColor(GetColor(8));
UpSignal2.SetDefaultColor(Color.UPTICK);
UpSignal2.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal2.SetDefaultColor(Color.DOWNTICK);
DownSignal2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

View attachment 24257

There might be some redundancy but it works.
can someone help to write the scan the triple RSI?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
328 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top