RSI - TSI Indicator For ThinkOrSwim

@Svanoy : Thank you for your latest reply and continuing guidance...The label functionality works great...

The last remaining issue is the plotting of the arrows...as illustrated below...

a.png



b.png


I got it! If you bang your head against the wall long enough, you either find the answer you were looking for or you pass out :LOL:

c.png


One more thing...how about coloring the appropriate candles to show when the signal is valid, so you can keep your eyes on the price action...

d.png


@Nich76 @jay2 : Below please find the final code complete with working Arrows, Labels and Alerts...

Code:
declare lower;

def na = Double.NaN;

script normalizer {
    input data   = close;
    input Min    = 0;
    input Max    = 100;
    input length = 50;

    def hhData   = Highest(data, length);
    def llData   = Lowest(data, length);

    plot resized = (((Max - Min) * (data - llData)) /

                       (hhData - llData)) + Min;
}


### Relative Strength Index (RSI) ###

input length = 14;
input price = close;
def averageType = AverageType.WILDERS;

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;

def RSI = 50 * (ChgRatio + 1);

plot x = normalizer(RSI);
x.SetDefaultColor(Color.GREEN);
x.SetLineWeight(3);


### True Strength Index (TSI) ###

input longLength = 25;
input shortLength = 13;
input averageType2 = AverageType.EXPONENTIAL;

def diff = close - close[1];
def doubleSmoothedAbsDiff = MovingAverage(averageType2, MovingAverage(averageType2, AbsValue(diff), longLength), shortLength);

def TSI;
TSI = if doubleSmoothedAbsDiff == 0 then 0
      else 100 * (MovingAverage(averageType2, MovingAverage(averageType2, diff, longLength), shortLength)) / doubleSmoothedAbsDiff;

plot y = normalizer(TSI);
y.SetDefaultColor(Color.RED);
y.SetLineWeight(3);

AddCloud(x,  y,  Color.GREEN,  Color.RED);


### Arrows, Labels, Alerts and Colored Price Action ###

def RSICrossAbove = x crosses above y;
def RSICrossBelow = x crosses below y;

def cross1 = if RSICrossAbove then x else Double.NaN;
def cross2 = if RSICrossBelow then x else Double.NaN;

plot x1 = cross1;
x1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
x1.SetLineWeight(3);
x1.SetDefaultColor(Color.YELLOW);
plot x2 = cross2;
x2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
x2.SetLineWeight(3);
x2.SetDefaultColor(Color.YELLOW);

AddLabel(if RSICrossAbove then yes else no, "RSI crossed above TSI" , Color.LIGHT_GREEN);
AddLabel(if RSICrossBelow then yes else no, "RSI crossed below TSI" , Color.PINK);

Alert(RSICrossAbove, "RSI crossed above TSI" , Alert.BAR, Sound.Bell);
Alert(RSICrossBelow, "RSI crossed below TSI" , Alert.BAR, Sound.Bell);

AssignPriceColor(if RSICrossAbove then Color.YELLOW else if RSICrossBelow then Color.YELLOW else Color.CURRENT);


Good Luck and Good Trading :cool:
 
@ganq : Thanks for the "heads up"...I certainly agree with you, there is no need to have two very similar studies on your charts...

I looked for the RSI Crossover...I found the Ultimate RSI Indicator by @horserider, but failed to see a similarity...Could you post a link so I can take a look at the RSI Crossover? Thanks!
Hi @netarchitech - Here is the snap showing both the RSI-TSI indicator at bottom and also the RSI MA Crossover. The plots do seem a bit similar but I am not sure if they are the same thing.

RSI-TSI vs RSI-MA-Crossover-Horserider
 
Here is the snap showing both the RSI-TSI indicator at bottom and also the RSI MA Crossover. The plots do seem a bit similar but I am not sure if they are the same thing.

Hi @ganq : Thanks for following up and supplying the comparative screenshot...I agree with you, I don't see a striking similarity, but I would like to get to the bottom of this conumdrum...

Unfortunately, the screenshot lacks the ticker for the stock/future and the timeframe is unknown as well. If you have a moment, could you forward that information to me, as well as the thinkscript for the "RSI MA Crossover", if available...This additional information would really help with a more in-depth comparison...I would really like to definitively know the answer to this question...
 
Hi @ganq : Thanks for following up and supplying the comparative screenshot...I agree with you, I don't see a striking similarity, but I would like to get to the bottom of this conumdrum...

Unfortunately, the screenshot lacks the ticker for the stock/future and the timeframe is unknown as well. If you have a moment, could you forward that information to me, as well as the thinkscript for the "RSI MA Crossover", if available...This additional information would really help with a more in-depth comparison...I would really like to definitively know the answer to this question...
Hi @netarchitech - I have uploaded another screenshot of the entire chart at the same link: - Hope this help.

Also here is the RSI MA Crossover Study from HorseRider: https://tos.mx/5bXtPWL

Thank you!
 
Hi @ganq : Thank you for your time and effort tracking down all the remaining pieces to this puzzle...I really appreciate it!

Below is a comparison of the two studies...The reason why the studies look similar is because they both share a 14 period RSI with a HULL moving average applied...

z.png


Have a good weekend...

Good Luck and Good Trading :cool:
 
@Svanoy : Thank you for your latest reply and continuing guidance...The label functionality works great...

The last remaining issue is the plotting of the arrows...as illustrated below...

a.png



b.png


I got it! If you bang your head against the wall long enough, you either find the answer you were looking for or you pass out :LOL:

c.png


One more thing...how about coloring the appropriate candles to show when the signal is valid, so you can keep your eyes on the price action...

d.png


@Nich76 @jay2 : Below please find the final code complete with working Arrows, Labels and Alerts...

Code:
declare lower;

def na = Double.NaN;

script normalizer {
    input data   = close;
    input Min    = 0;
    input Max    = 100;
    input length = 50;

    def hhData   = Highest(data, length);
    def llData   = Lowest(data, length);

    plot resized = (((Max - Min) * (data - llData)) /

                       (hhData - llData)) + Min;
}


### Relative Strength Index (RSI) ###

input length = 14;
input price = close;
def averageType = AverageType.WILDERS;

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;

def RSI = 50 * (ChgRatio + 1);

plot x = normalizer(RSI);
x.SetDefaultColor(Color.GREEN);
x.SetLineWeight(3);


### True Strength Index (TSI) ###

input longLength = 25;
input shortLength = 13;
input averageType2 = AverageType.EXPONENTIAL;

def diff = close - close[1];
def doubleSmoothedAbsDiff = MovingAverage(averageType2, MovingAverage(averageType2, AbsValue(diff), longLength), shortLength);

def TSI;
TSI = if doubleSmoothedAbsDiff == 0 then 0
      else 100 * (MovingAverage(averageType2, MovingAverage(averageType2, diff, longLength), shortLength)) / doubleSmoothedAbsDiff;

plot y = normalizer(TSI);
y.SetDefaultColor(Color.RED);
y.SetLineWeight(3);

AddCloud(x,  y,  Color.GREEN,  Color.RED);


### Arrows, Labels, Alerts and Colored Price Action ###

def RSICrossAbove = x crosses above y;
def RSICrossBelow = x crosses below y;

def cross1 = if RSICrossAbove then x else Double.NaN;
def cross2 = if RSICrossBelow then x else Double.NaN;

plot x1 = cross1;
x1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
x1.SetLineWeight(3);
x1.SetDefaultColor(Color.YELLOW);
plot x2 = cross2;
x2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
x2.SetLineWeight(3);
x2.SetDefaultColor(Color.YELLOW);

AddLabel(if RSICrossAbove then yes else no, "RSI crossed above TSI" , Color.LIGHT_GREEN);
AddLabel(if RSICrossBelow then yes else no, "RSI crossed below TSI" , Color.PINK);

Alert(RSICrossAbove, "RSI crossed above TSI" , Alert.BAR, Sound.Bell);
Alert(RSICrossBelow, "RSI crossed below TSI" , Alert.BAR, Sound.Bell);

AssignPriceColor(if RSICrossAbove then Color.YELLOW else if RSICrossBelow then Color.YELLOW else Color.CURRENT);


Good Luck and Good Tradig
netarchitech, sorry I am just now responding. I have been traveling and left my laptop. I have loaded V2 and V3 as Studies in TOS. I have also added the first version in Strategies. When I ran a report on the first version, the report showed 67 buy/sell signals with pver $1,700 profit. The third version looks much better, and I can't wait to use it. The first version looked so good on mobile, I used it to trade SPY options and profitted over $1,900 on one trade. Thank you for helping with this. I knew it was going to be great!
 
@Nich76 : No worries with respect to just responding now. Hope you had a good trip...

Congratulations on your recent trading successes! It's great to know a little collaboration and some elbow grease can yield some nice dividends. All the best and continuing success going forward...

Good Luck and Good Trading :cool:
 
@Nich76 : No worries with respect to just responding now. Hope you had a good trip...

Congratulations on your recent trading successes! It's great to know a little collaboration and some elbow grease can yield some nice dividends. All the best and continuing success going forward...

Good Luck and Good Trading :cool:
hey @netarchitech ! im newbie so forgive my question if it sounds silly , The TSI shows from -100 to 100 when I have it on my chart how is it able to cross RSI again forgive my question if its silly or something Im missing . thanks !
 
Hey there @rlove1221 : No worries with respect to questions, silly or otherwise, so let's see if can provide a reasonable answer to your question...

TSI and RSI are normally plotted using different scales, TSI = -100 to 100, as you pointed out, and RSI = 0 to 100...If you were to drag and drop RSI right on top of TSI, there would be a scaling conflict and thinkorswim would accommodate by changing the scale to 0% to 100%, which yields potentially problematic results...

The illustration below shows several combinations of the default RSI and TSI, respectively...

a.png


Notice, in example 1, the scale is from 0% to 100%...This is the "drag and drop" version...As far as issues go, the main one is the misplacement of the zero line...The irony is that the line data (RSI and TSI) is handled better and looks closer to what it should than examples 2 and 3...

Examples 2 and 3, having been "normalized", face another issue...Essentially, as pointed out by the arrows above, the RSI and TSI "flatline"...Is it a data issue, a software issue or possibly both?

It would appear that the scaling solution needs to be revisited by one or more of the coding gurus here at uTS to see if there is anything that can be done to possibly resolve the dilemma...

@rlove1221 : Unfortunately I don't think I answered your question completely...Maybe others will chime in and provide additional information and perspective...

Hope this helps...

Good Luck and Good Trading :cool:
 
Hey there @rlove1221 : No worries with respect to questions, silly or otherwise, so let's see if can provide a reasonable answer to your question...

TSI and RSI are normally plotted using different scales, TSI = -100 to 100, as you pointed out, and RSI = 0 to 100...If you were to drag and drop RSI right on top of TSI, there would be a scaling conflict and thinkorswim would accommodate by changing the scale to 0% to 100%, which yields potentially problematic results...

The illustration below shows several combinations of the default RSI and TSI, respectively...

a.png


Notice, in example 1, the scale is from 0% to 100%...This is the "drag and drop" version...As far as issues go, the main one is the misplacement of the zero line...The irony is that the line data (RSI and TSI) is handled better and looks closer to what it should than examples 2 and 3...

Examples 2 and 3, having been "normalized", face another issue...Essentially, as pointed out by the arrows above, the RSI and TSI "flatline"...Is it a data issue, a software issue or possibly both?

It would appear that the scaling solution needs to be revisited by one or more of the coding gurus here at uTS to see if there is anything that can be done to possibly resolve the dilemma...

@rlove1221 : Unfortunately I don't think I answered your question completely...Maybe others will chime in and provide additional information and perspective...

Hope this helps...

Good Luck and Good Trading :cool:
Thanks for answering and you did explain !!i wasnt sure how the percentage was calculated and by showing the other 2 examples it makes more sense. Thanks Again !! I added ADX as another bottom chart to see if it would help filter not sure if it would.
 
Last edited by a moderator:
Anyone able to scan for when RSI crosses over the TSI?
Shared Scanner link: http://tos.mx/B7fMyDV Click here for --> Easiest way to load shared links
kYdMXuH.png

Ruby:
# RSI-TSI

def na = Double.NaN;

script normalizer {
    input data   = close;
    input Min    = 0;
    input Max    = 100;
    input length = 50;

    def hhData   = Highest(data, length);
    def llData   = Lowest(data, length);

    plot resized = (((Max - Min) * (data - llData)) /

                       (hhData - llData)) + Min;
}


### Relative Strength Index (RSI) ###

input length = 14;
input price = close;
def averageType = AverageType.WILDERS;

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;

def RSI = 50 * (ChgRatio + 1);
def x = normalizer(RSI);

### True Strength Index (TSI) ###

input longLength = 25;
input shortLength = 13;
input averageType2 = AverageType.EXPONENTIAL;

def diff = close - close[1];
def doubleSmoothedAbsDiff = MovingAverage(averageType2, MovingAverage(averageType2, AbsValue(diff), longLength), shortLength);

def TSI;
TSI = if doubleSmoothedAbsDiff == 0 then 0
      else 100 * (MovingAverage(averageType2, MovingAverage(averageType2, diff, longLength), shortLength)) / doubleSmoothedAbsDiff;

def y = normalizer(TSI);


plot RSICrossAbove = x crosses above y;
#plot RSICrossBelow = x crosses below y;
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
244 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