• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

Connors 2 Period RSI Trading Indicator for ThinkorSwim

markos

Well-known member
VIP
Earlier there was mention of Connors RSI(2) Strategy

There are 4 steps to the strategy. Get it Here (Also an excellent resource for Technical Analysis: https://school.stockcharts.com/doku.php?id=trading_strategies:rsi2

A chart will be coming when I get my fried CPU back from repair.

Code:
# ConnorsRSI Indicator

declare lower;

input Price_RSI_Period = 3;
input Streak_RSI_Period = 2;
input Rank_Lookback = 100;
input OVER_BOUGHT = 90;
input OVER_SOLD = 10;
input SR_LENGTH = 35;
input PRICE = CLOSE;

# Component 1: the RSI of closing price
def priceRSI = reference RSI("price" = PRICE, "length" = Price_RSI_Period);

# Component 2: the RSI of the streak
def upDay = if PRICE > PRICE[1] then 1 else 0;
def downDay = if PRICE < PRICE[1] then -1 else 0;
def upStreak = if upDay != 0 then upStreak[1] + upDay else 0;
def downStreak = if downDay != 0 then downStreak[1] + downDay else 0;
def streak = upStreak + downStreak;
def streakRSI = reference RSI("price" = streak, "length" = Streak_RSI_Period);

# Componenet 3: The percent rank of the current return
def ROC1 = PRICE / PRICE[1] - 1;

def rank = fold i = 1 to Rank_Lookback + 1 with r = 0 do
r + (GetValue(ROC1, i, Rank_Lookback) < ROC1) ;

def pctRank = (rank / Rank_Lookback) * 100 ;

# The final ConnorsRSI calculation, combining the three components
plot ConnorsRSI = round((priceRSI + streakRSI + pctRank) / 3, NUMBEROFDIGITS = 0);

plot SR_HIGH = Round(Highest(ConnorsRSI, LENGTH = SR_LENGTH), NUMBEROFDIGITS = 0);

plot SR_LOW = Round(Lowest(ConnorsRSI, LENGTH = SR_LENGTH), NUMBEROFDIGITS = 0);

ConnorsRSI.AssignValueColor(if ConnorsRSI >= OVER_BOUGHT then Color.Red else if ConnorsRSI <= OVER_SOLD then Color.Green else Color.Gray);
ConnorsRSI.SetLineWeight(3);

SR_HIGH.SetDefaultColor(Color.CYAN);
SR_HIGH.SetLineWeight(1);

SR_LOW.SetDefaultColor(Color.CYAN);
SR_LOW.SetLineWeight(1);

plot OVERBOUGHT = OVER_BOUGHT;
OVERBOUGHT.SetDefaultColor(Color.DARK_GRAY);
OVERBOUGHT.Hide();
OVERBOUGHT.HideBubble();

plot OVERSOLD = OVER_SOLD;
OVERSOLD.SetDefaultColor(Color.DARK_GRAY);
OVERSOLD.Hide();
OVERSOLD.HideBubble();
 
Last edited:

horserider

Well-known member
VIP
@markos I showed the buys and sells in the other thread on Ultimate RSI. You could copy those here if you wish. Edit them if you think it is necessary. Definitely short term trading to stack very small profits up. You will be in and out most likely for a profit but will miss any long trend. I think it is only practical for an auto trading system.
 

markos

Well-known member
VIP
@horserider I would tend to agree with you about the practicality. I don't use it but others might. If not careful, one could blow up an account quick.

I created this thread because it was mentioned elsewhere and we, as a group, need to try and not deviate within a thread as I have done in the past. Then good ideas can get lost.
My CPU is fried, my only ToS is on mobile. I won't have my laptop back from repair for 1-2 weeks. :cry:

Please feel free and post your Connors RSI(2) here when you can.
If you do, please post it according to the rules laid out above, for the purists. ;)
 

deerock

New member
2019 Donor
Hi Ben, I saw a youtube video with a cool and simple trading strategy that uses the RSI as a trigger with over bought/oversold levels that are filtered out by a moving average of your choice. The link to the video is:

.

In essence, the user can define the moving average. Id prefer the 34 ema since I already use that on my charts. If price is above and RSI 2 period is below 10 then it is a dip buy opportunity. On the flip side if price is below the 34 ema and RSI is above 90 then it is a sell the rally opportunity.

Being able to run a scan for this would be nice. I did something simple using TOS but i know it isn't correct and gives me false alerts which I don't mind because at least it does show some decent looking opportunities I wouldn't have seen otherwise. The problem is I work too much to look at charts all day and figure out which ones I want or don't want to trade.
 
Last edited by a moderator:

BenTen

Administrative
Staff
VIP
See if this works for you. Included arrows to help you look for signals on the chart and also be able to use the Scanner with it.

B8ALbA7.png


Code:
# Simple 2 Period RSI Trading Indicator
# Assembled by BenTen at useThinkScript.com
# You are free to use this code for personal use, and make derivative works from it. You are NOT GRANTED permission to use this code (or derivative works) for commercial purposes which includes and is not limited to selling, reselling, or packaging with other commercial indicators. Headers and attribution in this code should remain as provided, and any derivative works should extend the existing headers.

# Start EMA
input price = close;
input length = 34;
input displace = 0;
#input showBreakoutSignals = no;

def AvgExp = ExpAverage(price[-displace], length);
#plot UpSignal = price crosses above AvgExp;
#plot DownSignal = price crosses below AvgExp;

# RSI
input RSIlength = 2;
input over_Bought = 90;
input over_Sold = 10;
input averageType = AverageType.WILDERS;
def NetChgAvg = MovingAverage(averageType, price - price[1], RSIlength);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), RSIlength);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def OverSold = over_Sold;
def OverBought = over_Bought;

def emaBull = price > AvgExp;
def emaBear = price < AvgExp;

# Define Warning Signals
def bullish = RSI(length = RSIlength, averageType = averageType) < over_Sold and emaBull;
def bearish = RSI(length = RSIlength, averageType = averageType) > over_Bought and emaBear;

# Paint the Trend
#AssignPriceColor(if bullish then Color.DARK_GREEN else if bearish then Color.DARK_RED else Color.CURRENT);

plot bull = bullish;
bull.AssignValueColor(Color.CYAN);
bull.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

plot bear = bearish;
bear.AssignValueColor(Color.CYAN);
bear.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

Shareable Link

https://tos.mx/GBnw6w
 
Last edited:

skynetgen

Well-known member
I just want to add. The most important thing to trade indicator is to understand what it means. RSI is - relative strength index. But what does period of 14 RSI with value 70 means? it means that 70% of time over the length the trend was rising. Not oversold , not overbought. But just precisely that
So by varying various length and tweaking "ob/os" we just tweaking indicator to tell us what kind of strength we looking for over what period of time

So RSI(2) 90/2 Is merely 4 bar ema strength signal (because 2 is wilders and wilders=2x EMA). with 90 means we want trend rising 90 of time(or 10 - conversely rising only 10 of time - e.g weakening). So there is no magic with this various length techniques. By using RSI(2)/RSI (14) you achieve confluence of larger price trend with shorter price trend. Whether it works on your particular timeframe and security is another matter

The most critical piece about oscillator like RSI is to determine the lenght. - e.g. the length over which cycle tend to occur. Using RSI OB/OS levels is in a way not much different than using candle count techniques (e.g 5 candles-in one trend - trend too overxtended. ) It is obvious why using OB/OS fails in long smooth trends - "the cycle" does not occur. it goes precisely as RSI tells it ( e.g over 80/90 candles are uptrending - nothing OB about it).
and hence why RSI/Stoch is a supposedely only good in ranged market (which typically have a clear cycle length)

Here is example of using RSI in different way:
1) find strong stock on long TF- e.g. "RSI(50)>70
2) On it find a shorter wave in sideways pullback RSI(21) ~50
3) And coming out of a downwave on faster timeframe RSI(13)crossing 50
 
Last edited:

deerock

New member
2019 Donor
@skynetgen Thx for the RSI tutorial. Definitely enlightening. I notice this kind of indicator suits a trending market so I will create a watchlist of stocks that mainly trend and use it on those.
 

muztem

New member
VIP
is there any chance this pinescript indicator transform for tos?

thanks in advance
Code:
//Created by ChrisMoody
//Based on Larry Connors RSI-2 Strategy - Lower RSI
study(title="_CM_RSI_2_Strat_Low", shorttitle="_CM_RSI_2_Strategy_Lower", overlay=false)
src = close,

//RSI CODE
up = rma(max(change(src), 0), 2)
down = rma(-min(change(src), 0), 2)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
//Criteria for Moving Avg rules
ma5 = sma(close,5)
ma200= sma(close, 200)

//Rule for RSI Color
col = close > ma200 and close < ma5 and rsi < 10 ? lime : close < ma200 and close > ma5 and rsi > 90 ? red : silver

plot(rsi, title="RSI", style=line, linewidth=4,color=col)
plot(100, title="Upper Line 100",style=line, linewidth=3, color=aqua)
plot(0, title="Lower Line 0",style=line, linewidth=3, color=aqua)

band1 = plot(90, title="Upper Line 90",style=line, linewidth=3, color=aqua)
band0 = plot(10, title="Lower Line 10",style=line, linewidth=3, color=aqua)
fill(band1, band0, color=silver, transp=90)
 

jcga1981

Member
Hi, I wanted to know if anyone can help me ...
Purchase Condition:
Time Frame M1
RSI (2) <10
Time Frame M5
RSI (7)> 60
RSI (7) <80
Time Frame M15
RSI (7)> 60
RSI (7) <80

Sale condition:
Time Frame M1
RSI (2)> 90
Time Frame M5
RSI (7) <40
RSI (7)> 20
Time Frame M15
RSI (7) <40
RSI (7)> 20

Is there a possibility of being in M1 and if the conditions in the three time frames are met, does an arrow appear indicating long or short?

Many thanks!!
 

ykd2018x

Member
2019 Donor
VIP
@jcga1981

i see your comment here the idea is good but i m not very sure weather rsi(2) will hit below 10 on 1 min time frame while being above 60 in 5 min time frame because being above 60 on 5 min with rsi(7) is bullish but it still deserve a check

coz i am the one who introduce here rsi(7) >60 trading technique

i am not a coder so still its better that the developers in this forum shuld help it
 
@skynetgen what are you referring to when you use this line (~) And what time frame is this strategy used on?

Can someone help me create a scan based on this script. I want to scan for signals when RSI falls below 5.

Code:
# ConnorsRSI Indicator
declare lower;
input Price_RSI_Period = 3;
input Streak_RSI_Period = 2;
input Rank_Lookback = 100;
# Component 1: the RSI of closing price
def priceRSI = reference RSI("price" = close, "length" = Price_RSI_Period);
# Component 2: the RSI of the streak
def upDay = if close > close[1] then 1 else 0;
def downDay = if close < close[1] then -1 else 0;
def upStreak = if upDay != 0 then upStreak[1] + upDay else 0;
def downStreak = if downDay != 0 then downStreak[1] + downDay else 0;
def streak = upStreak + downStreak;
def streakRSI = reference RSI("price" = streak, "length" = Streak_RSI_Period);
# Component 3: The percent rank of the current return
def ROC1 = close / close[1] - 1;
def rank = fold i = 1 to Rank_Lookback + 1 with r = 0 do
r + (GetValue(ROC1, i, Rank_Lookback) < ROC1) ;
def pctRank = (rank / Rank_Lookback) * 100 ;
# The final ConnorsRSI calculation, combining the three components
plot ConnorsRSI = (priceRSI + streakRSI + pctRank) / 3;
 

Heloyguerra

New member
I had this custom coded but im not getting many signals when I do get a signal it works great but its once in a blue moon. Can someone look and see if you can tweek for more signals?

Code:
# MTS200517 Scan for Hector eml
# Name: MTS_HectorII_200517Scan
# Intended to run on daily TF only
declare hide_on_intraday;
Declare Lower;
Input W_PercentBelowPriorClose = 3;
Input X_BottomPercentileLimit = 10;
Input ConnorsRSILimit = 5;

Def CloseCond = close>5;
Def AvgVolCond = average(volume,21)>250000;
Def ADXCond = ADX(10)>30;
Def WCond = low<(100-W_PercentBelowPriorClose)/100*Low[1];
Def XCond = High-close > (100-X_BottomPercentileLimit)/100 * (high-low);

# MTS2005 Connors RSI Interpretation
# declare lower;
input ClasicRSILenght = 3;
input StreakRSILenght = 2;
input PercentRankLookback = 30;
# Clasic RSI
def priceRSI = RSI(ClasicRSILenght);
# RSI of the streak
def upDay = close > close[1];
def downDay = close < close[1];
def upStreak = if upDay then upStreak[1] + upDay else 0;
def downStreak = if downDay then downStreak[1] - downDay else 0;
def streak = upStreak + downStreak;
def streakRSI = RSI("price" = streak, "length" = StreakRSILenght);
# Percent rank
def ROC1 = close / close[1] - 1;
def rank = fold i = 1 to PercentRankLookback + 1 with r = 0 do
r + (GetValue(ROC1, i, PercentRankLookback) < ROC1) ;
def pctRank = (rank / PercentRankLookback) * 30 ;
# ConnorsRSI Final
Def ConnorsRSI = (priceRSI + streakRSI + pctRank) / 3;

Def ConnorsCond = ConnorsRSI<ConnorsRSILimit;

Plot Scan =  CloseCond AND AvgVolCond AND ADXCond AND WCond AND XCond AND ConnorsCond;
 
Last edited by a moderator:

Prison Mike

Member
I’ll play around with it when I can.

I would advise to learn what the code is doing and play around with the values in this part of the code .

Input W_PercentBelowPriorClose = 3;
Input X_BottomPercentileLimit = 10;
Input ConnorsRSILimit = 5;

Def CloseCond = close>5;
Def AvgVolCond = average(volume,21)>250000;
Def ADXCond = ADX(10)>30;
Def WCond = low<(100-W_PercentBelowPriorClose)/100*Low[1];
Def XCond = High-close > (100-X_BottomPercentileLimit)/100 * (high-low);
 

Prison Mike

Member
"connerRSI() is less than or equal to 5"

Study needs to be named connerRSI

This can be made in the "scan" portion of TOS
 
@markos and @horserider

Do you guys have any idea how I could use the connor RSI into a scan. Here is the script if you don't have it:

Code:
# ConnorsRSI Indicator
declare lower;
input Price_RSI_Period = 3;
input Streak_RSI_Period = 2;
input Rank_Lookback = 100;
# Component 1: the RSI of closing price
def priceRSI = reference RSI("price" = close, "length" = Price_RSI_Period);
# Component 2: the RSI of the streak
def upDay = if close > close[1] then 1 else 0;
def downDay = if close < close[1] then -1 else 0;
def upStreak = if upDay != 0 then upStreak[1] + upDay else 0;
def downStreak = if downDay != 0 then downStreak[1] + downDay else 0;
def streak = upStreak + downStreak;
def streakRSI = reference RSI("price" = streak, "length" = Streak_RSI_Period);
# Component 3: The percent rank of the current return
def ROC1 = close / close[1] - 1;
def rank = fold i = 1 to Rank_Lookback + 1 with r = 0 do
r + (GetValue(ROC1, i, Rank_Lookback) < ROC1) ;
def pctRank = (rank / Rank_Lookback) * 100 ;
# The final ConnorsRSI calculation, combining the three components
plot ConnorsRSI = (priceRSI + streakRSI + pctRank) / 3;

When I try to use the condition wizard I get "error script execution timeout"

The scan would be for an RSI lower than 5.
 
Top