Can anyone help me clean this Triple RSI up a little?

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.

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:
which time frame is the best to use the triple RSI?

which time frame is the best to use the triple RSI?

I've been playing with it on the higher timeframes from 1hr up to the daily charts.

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

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

Can you elaborate on this?

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

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:
#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.

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.

Not the exact question you're looking for?

87k+ Posts
229 Online

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?