2 Period RSI Trading Indicator for ThinkorSwim

D

deerock

New member
VIP
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

BenTen

Administrative
Staff
VIP
Warehouse
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.



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

 
Last edited:
S

skynetgen

Member
Warehouse
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:
D

deerock

New member
VIP
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

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.
 

Top