IBD Stock Charts Style and Scan for ThinkorSwim

@RDMercer Thank you! I appreciate that. I spent hours on end coming up with the 5 indicators in this thread. The last one of the 5 is the one that is in the original chart that you see in the lower panel.
I tested them by sorting all 5 by hi -low and seeing how the %MA columns and the 1, 3, and 6 month returns came out.
I also plotted the %CTM in the Lower with the % of 52 week line. I liked how that worked out.

Please run it through its paces, as a community, I would like to know how both the Marketwatch Columns work as well as which seem to make sense in the lower pane or inside the volume lower. AT Your Time Frame.
 
Last edited:
@arthurx I do need to revisit this, it just may be a while. I was thinking of something akin to this:
2*(c/c63)+1.25*(c/c126)+(c/c189)+0.75*(c/c252) then /4. I just don't know. I've been tied up for a while and will continue to be.

I have a few trials in Market Watch Columns that show quite a different take on the work I have done.
The release of the variations should be released by end of October. One of the codes uses too much data and I run over the limit.

If anyone would like to throw their code at the wall to see if it sticks, please feel free to do so! :) I'm sure @MBF has some ideas!!:eek:
@markos Pls check if these are correct, i have asked my friend to code both of them. I have tested both and there is only slight difference btw both reading.

plot rs = ((2*(close/close[63])+(close/close[126])+(close/189)+(close/252))/4);

plot rs = ((2*(close/close[63])+1.25*(close/close[126])+(close/189)+0.75*(close/252))/4);
 
@markos Pls check if these are correct, i have asked my friend to code both of them. I have tested both and there is only slight difference btw both reading.
plot rs = ((2*(close/close[63])+(close/close[126])+(close/189)+(close/252))/4);
plot rs = ((2*(close/close[63])+1.25*(close/close[126])+(close/189)+0.75*(close/252))/4);
@Nick Happy New Year Both of the codes I have posted here are on my watchlist. @dougn I cannot decently duplicate the IBD RS Line.
Nick, I did try your code above and named it NRelSt (please see what I have tried via (#) commenting out).
Your code works well as a longer term RS and I use it with my CTMrs code which is an excellent very short term, fast RS for a Watch List Column. Both codes will throw a Complex Code Alert so keep your watchlist short to begin with. Try them & see... Thanks, Markos

PS There is NO share link for these because share links for Custom Columns is Bad Practice, They cannot be deleted.
Longer Term Watch List Column
Code:
# WLC NRelSt
# WatchListColumn TSL 09:56 Dave_S: # October 9 2019
# Hi markos: here's is your repaired script;
#
# I am attempting to create my own version of a RS Rating watchlist column that is weighted to the latest 3 months.  This little code throws a complex script warning .
# The idea here is a hack to create a Weighted Relative Strength

# V2.0 12-29-19 Added Data 2 code from uTS Nick & Commented out my Data 2 as well as Changed Data1 1 to ITOT which is Total Stock Market ETF
V2.1 12-31-19 Changed Data1 back to close / Average(close, 6); For some reason, without this setting, NaN comes up on most numbers. Fixed now.

# Uncomment (#)  declare lower & plots at bottom if you want it on a chart.

#declare lower;

input lengthYR = 252;
input length3QTRs = 189;
input lengthHalfYr = 126;
input lengthQTR = 63;
input lengthWk = 6;
# input mid = 50;

  def C252 = Average(close, lengthYR);
  def C189  = Average(close, length3QTRs);
  def C126  = Average(close, lengthHalfYr);
  def C63  = Average(close, lengthQTR);
  def C6 = Average(close, lengthWk);

#def Data1 = close / close("SPX");
def Data1 = close / Average(close, 6);
# def Data2 = (((2*(c/c63))+(1.25*(c/c126))+(c/c189)+(0.75*(c/c252)))/4);
#def lastms Data2 = (((2*(close/c63))+(1.00*(close/c126))+(0.75*(close/c189))+(0.50*(close/c252)))/4);
# def Data2 = (((5*(close/c63))+(3.00*(close/c126))+(1.00*(close/c189))+(0.25*(close/c252)))/4);
def Data2 = ((2*(close/close[63])+1.25*(close/close[126])+(close/189)+0.75*(close/252))/4);
def Data3 = Data1 * Data2;
def newRngMin = 1;
def newRngMax = 100;
def HHData3 = HighestAll( Data3);
def LLData3 = LowestAll( Data3 );
plot nr = ((( newRngMax - newRngMin ) * ( Data3 - LLData3 )) / ( HHData3 - LLData3 )) + newRngMin;
#plot midline = mid;
# End MyexpRS3 Markos
# Renamed NRelSt 12-29-19
##

Fast - Short Time Frame WLC
Code:
# WLC  %CTM
# Created by Mobius for Markos request in TSL 2019
# Chande Trend Meter ported from StockCharts dot com by Mobius.  This Trend Meter from Tushar Chande is very fast and uses 4 indicators to show direction; Bollinger Bands, RSI, Z-Score, and Price Channel.
# Uncomment declare lower & plots at bottom if you want it on a chart.

#declare lower;

def h = high;
def l = low;
def c = close;
script Scale {
    input c = close;
    input Min = 0;
    input Max = 100;
    def hh = HighestAll(c);
    def ll = LowestAll(c);
    plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;
}
script BB
    {
    input price = close;
    input length = 20;
    def avg = Average(price, length);
    def sd = StDev(price, length);
    def upperBand = avg + (2 * sd);
    def lowerBand = avg - (2 * sd);
    plot PercentB = (price - lowerBand) / (upperBand - lowerBand) * 10;
}
def BB20H = BB(h, 20);
def BB20L = BB(l, 20);
def BB20C = BB(c, 20);
def BB50H = BB(h, 50);
def BB50L = BB(l, 50);
def BB50C = BB(c, 50);
def BB75H = BB(h, 75);
def BB75L = BB(l, 75);
def BB75C = BB(c, 75);
def BB100H = BB(h, 100);
def BB100L = BB(l, 100);
def BB100C = BB(c, 100);
def zScore = ((c - Average(c, 100)) / StDev(c, 100)) * 10;
def RSI = RSI() / 10;
def PriceChannel = ((c - Lowest(l, 2)) / (Highest(h, 2) - Lowest(l, 2))) * 10;
def sum = BB20H + BB20L + BB20C + BB50H + BB50L + BB50C + BB75H + BB75L + BB75C + BB100H + BB100L + BB100C + zScore + RSI + PriceChannel;
plot CTM = scale(sum);
#plot "90" = if isNaN(c) then double.nan else 90;
#plot "80" = if isNaN(c) then double.nan else 80;
#plot "60" = if isNaN(c) then double.nan else 60;
#plot "20" = if isNaN(c) then double.nan else 20;
# End Code CTM

Happy New Year
 
Last edited:
@Nick Happy New Year Both of the codes I have posted here are on my watchlist. @dougn I cannot decently duplicate the IBD RS Line.
Nick, I did try your code above and named it NRelSt (please see what I have tried via (#) commenting out).
Your code works well as a longer term RS and I use it with my CTMrs code which is an excellent very short term, fast RS for a Watch List Column. Both codes will throw a Complex Code Alert so keep your watchlist short to begin with. Try them & see... Thanks, Markos

Longer Term Watch List Column
Code:
# WLC NRelSt
# WatchListColumn TSL 09:56 Dave_S: # October 9 2019
# Hi markos: here's is your repaired script;
#
# I am attempting to create my own version of a RS Rating watchlist column that is weighted to the latest 3 months.  This little code throws a complex script warning .
# The idea here is a hack to create a Weighted Relative Strength

# V2.0 12-29-19 Added Data 2 code from uTS Nick & Commented out my Data 2 as well as Changed Data1 1 to ITOT which is Total Stock Market ETF

#declare lower;

input lengthYR = 252;
input length3QTRs = 189;
input lengthHalfYr = 126;
input lengthQTR = 63;
input lengthWk = 6;
# input mid = 50;

  def C252 = Average(close, lengthYR);
  def C189  = Average(close, length3QTRs);
  def C126  = Average(close, lengthHalfYr);
  def C63  = Average(close, lengthQTR);
  def C6 = Average(close, lengthWk);

def Data1 = close / close("ITOT");
#def Data1 = close / Average(close, 6);
# def Data2 = (((2*(c/c63))+(1.25*(c/c126))+(c/c189)+(0.75*(c/c252)))/4);
#def lastms Data2 = (((2*(close/c63))+(1.00*(close/c126))+(0.75*(close/c189))+(0.50*(close/c252)))/4);
# def Data2 = (((5*(close/c63))+(3.00*(close/c126))+(1.00*(close/c189))+(0.25*(close/c252)))/4);
def Data2 = ((2*(close/close[63])+1.25*(close/close[126])+(close/189)+0.75*(close/252))/4);
def Data3 = Data1 * Data2;
def newRngMin = 1;
def newRngMax = 100;
def HHData3 = HighestAll( Data3);
def LLData3 = LowestAll( Data3 );
plot nr = ((( newRngMax - newRngMin ) * ( Data3 - LLData3 )) / ( HHData3 - LLData3 )) + newRngMin;
#plot midline = mid;

# End MyexpRS3 Markos
# Renamed NRelSt 12-29-19
##

Fast Short Time Frame WLC
Code:
# WLC  %CTM
# Created by Mobius for Markos request in TSL 2019
# Chande Trend Meter ported from StockCharts dot com by Mobius.  This Trend Meter from Chande Tushar is very fast and uses 4 indicators to show direction; Bollinger Bands, RSI, Z-Score, and Price Channel.
# Uncomment declare lower & plots at bottom if you want it on a chart.

#declare lower;

def h = high;
def l = low;
def c = close;
script Scale {
    input c = close;
    input Min = 0;
    input Max = 100;
    def hh = HighestAll(c);
    def ll = LowestAll(c);
    plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;
}
script BB
    {
    input price = close;
    input length = 20;
    def avg = Average(price, length);
    def sd = StDev(price, length);
    def upperBand = avg + (2 * sd);
    def lowerBand = avg - (2 * sd);
    plot PercentB = (price - lowerBand) / (upperBand - lowerBand) * 10;
}
def BB20H = BB(h, 20);
def BB20L = BB(l, 20);
def BB20C = BB(c, 20);
def BB50H = BB(h, 50);
def BB50L = BB(l, 50);
def BB50C = BB(c, 50);
def BB75H = BB(h, 75);
def BB75L = BB(l, 75);
def BB75C = BB(c, 75);
def BB100H = BB(h, 100);
def BB100L = BB(l, 100);
def BB100C = BB(c, 100);
def zScore = ((c - Average(c, 100)) / StDev(c, 100)) * 10;
def RSI = RSI() / 10;
def PriceChannel = ((c - Lowest(l, 2)) / (Highest(h, 2) - Lowest(l, 2))) * 10;
def sum = BB20H + BB20L + BB20C + BB50H + BB50L + BB50C + BB75H + BB75L + BB75C + BB100H + BB100L + BB100C + zScore + RSI + PriceChannel;
plot CTM = scale(sum);
#plot "90" = if isNaN(c) then double.nan else 90;
#plot "80" = if isNaN(c) then double.nan else 80;
#plot "60" = if isNaN(c) then double.nan else 60;
#plot "20" = if isNaN(c) then double.nan else 20;
# End Code CTM

Happy New Year
@markos Happy New Year.
May i know how do we use or interpret the scan results from the two scripts you posted? I could only get some output from Fast Short Term Frame in WLC but NaA output from the long term Watch list Column. I presume we are not supposed to see any plot ?? May i request if you could screenshot your output for ease of comparison. Apologies for the long request. Thanks
 
@markos Pls check if these are correct, i have asked my friend to code both of them. I have tested both and there is only slight difference btw both reading.

plot rs = ((2*(close/close[63])+(close/close[126])+(close/189)+(close/252))/4);

plot rs = ((2*(close/close[63])+1.25*(close/close[126])+(close/189)+0.75*(close/252))/4);
Nick, both are correct. Only difference is that the first one is straight weighted. They both weigh the recent quarter at 2x the other qtrs.
 
Ok, been jacking around with this for a bit and this is the O'neil ranking system I came up with. No way in hell is it the same as IBD but its nice on its own. Its another simple performance of 3,6,9,12 quarter with double weighting to first quarter. it then compares the sum of these 4 weighted returns to the absolute max return the stock could have made comparing highest to lowest. This is essentially how o'neil said it was set up on his site

o'neil explanation

When you put this next to some of the other ranking systems you have you'll notice it does NOT come close a lot of the time. It seveeerely punishes stocks that haven't kept holding an efficient trend for the year. Chopping won't cut it with this so it's a nice tool to have if you want stocks with predictability. This double weighted last quarter obliterated the ranking on quite of few of these it looks like. Definitely worth taking a look at for longer term traders IMO


Code:
#    O'Neil price performance RS ranking
#    WTF_Dude
#    5.5.20
#    color styling codes from #WLC_RS1Yr RS_Rank by GHorschman
#     `
#    RS_Rank > 80       -- Dark Green
#    80 <= RS_Rank < 60 -- Light Green
#    60 <= RS_Rank < 40 -- Gray
#    40 <= RS_Rank < 20 -- Light Red
#    RS_Rank <= 20      -- Dark Red
######################################################################

# Set length to period of interest.

#  1 Wk – 5 trading days
#  1 Mos – 21 Days
#  3 Mos – 63 Days
#  6 Mos – 126 Days
#  12 Mos – 252 Days

def year = if close-close[252] is less than 0 then 0 else close-close[252] ;
def nine =  if close-close[189] is less than 0 then 0 else close-close[189] ;
def six =  if close-close[126] is less than 0 then 0 else close-close[126] ;;
def three = if close-close[63] is less than 0 then 0 else close-close[63] ;;
def weighted = if ((2*three) + six + nine + year)/4 is less than 0 then 0 else ((2*three + six + nine + year)/4); #decimal

def h = highest(high, 252);
def l = lowest(low, 252);
def hilo = absvalue(h-l);
def calc = weighted/ hilo;

plot rsrank = round(100* calc,0);
#addlabel (yes,RSRank);

#AddLabel (yes, if  RSRank >= 1 and RSRank < 100 then "000" + astext(RSRank) else astext( RSRank)   );

assignbackgroundcolor (if RSRank > 80 then color.dark_green else
                       if RSRank > 60 and RSRank <= 80 then createcolor(0,175,0) else
                       if RSRank > 40 and RSRank <= 60 then color.gray else
                       if RSRank > 20 and RSRank <= 40 then CreateColor(220, 0,0) else
                       if RSRank <= 20 then CreateColor(150, 0,0) else
                       color.white);
 
Ok, been jacking around with this for a bit and this is the O'neil ranking system I came up with. No way in hell is it the same as IBD but its nice on its own. Its another simple performance of 3,6,9,12 quarter with double weighting to first quarter. it then compares the sum of these 4 weighted returns to the absolute max return the stock could have made comparing highest to lowest. This is essentially how o'neil said it was set up on his site

o'neil explanation

When you put this next to some of the other ranking systems you have you'll notice it does NOT come close a lot of the time. It seveeerely punishes stocks that haven't kept holding an efficient trend for the year. Chopping won't cut it with this so it's a nice tool to have if you want stocks with predictability. This double weighted last quarter obliterated the ranking on quite of few of these it looks like. Definitely worth taking a look at for longer term traders IMO


Code:
#    O'Neil price performance RS ranking
#    WTF_Dude
#    5.5.20
#    color styling codes from #WLC_RS1Yr RS_Rank by GHorschman
#     `
#    RS_Rank > 80       -- Dark Green
#    80 <= RS_Rank < 60 -- Light Green
#    60 <= RS_Rank < 40 -- Gray
#    40 <= RS_Rank < 20 -- Light Red
#    RS_Rank <= 20      -- Dark Red
######################################################################

# Set length to period of interest.

#  1 Wk – 5 trading days
#  1 Mos – 21 Days
#  3 Mos – 63 Days
#  6 Mos – 126 Days
#  12 Mos – 252 Days

def year = if close-close[252] is less than 0 then 0 else close-close[252] ;
def nine =  if close-close[189] is less than 0 then 0 else close-close[189] ;
def six =  if close-close[126] is less than 0 then 0 else close-close[126] ;;
def three = if close-close[63] is less than 0 then 0 else close-close[63] ;;
def weighted = if ((2*three) + six + nine + year)/4 is less than 0 then 0 else ((2*three + six + nine + year)/4); #decimal

def h = highest(high, 252);
def l = lowest(low, 252);
def hilo = absvalue(h-l);
def calc = weighted/ hilo;

plot rsrank = round(100* calc,0);
#addlabel (yes,RSRank);

#AddLabel (yes, if  RSRank >= 1 and RSRank < 100 then "000" + astext(RSRank) else astext( RSRank)   );

assignbackgroundcolor (if RSRank > 80 then color.dark_green else
                       if RSRank > 60 and RSRank <= 80 then createcolor(0,175,0) else
                       if RSRank > 40 and RSRank <= 60 then color.gray else
                       if RSRank > 20 and RSRank <= 40 then CreateColor(220, 0,0) else
                       if RSRank <= 20 then CreateColor(150, 0,0) else
                       color.white);
@wtf_dude A valiant effort. As you noticed from reading the beginning, I twisted my brain around it a number of times, to no avail. Something that TOS just released is a built in called "RSMK" which was published in TASC. Try it out as a comparison. Let us know what you think...

Also, I haven't looked but heard that someone like TraderLion on twitter showed how to create it on Stock Charts dot com. TraderLion is run by Ross Haber, Ross helped Wm O'Neil create his first, extensive electronic chart book in the 1980's, iirc.
@dougn are you familiar with either of these two items?
 
@wtf_dude A valiant effort. As you noticed from reading the beginning, I twisted my brain around it a number of times, to no avail. Something that TOS just released is a built in called "RSMK" which was published in TASC. Try it out as a comparison. Let us know what you think...

Also, I haven't looked but heard that someone like TraderLion on twitter showed how to create it on Stock Charts dot com. TraderLion is run by Ross Haber, Ross helped Wm O'Neil create his first, extensive electronic chart book in the 1980's, iirc.
@dougn are you familiar with either of these two items?
Haha I think I was actually the one that brought up the RSMK either here or another thread to another user. It's badass for what it is.The difference is RSMK is strength relative to an index. This is an indicator of strength of performance and trend in relation to itself. As in how much did the stock go up over time vs the absolute max it could have gone up if it went straight from a 52w low to the 52w high. So a completely different mechanism/relativity to try here. O'neils writings don't usually talk about stocks in relation to just beating an index and I think its very likely he just has a performance formula and sorts it. Either way, something to work with
 
Last edited:
@markos On the RS 1 year, can you figure out why it can't be sorted numerically? I've switched it to plot on def rsrank instead and #out the addlabel and get nothing but NaN??
 
https://tos.mx/hfEeqh
NytzSNTl.jpg


Updated 9-5-19: In this shared Google Drive are 2 files:
1) a file comparison of yesterdays IBD Relative Strength direct from IBD, along with a listing of what the watchlist code reads for the same security. If you follow the stocks in IBD's 85-85 list, my hope is that you would find most of them ranked above 70 in the watchlist column.
2) the picture is of the watchlist code on the right on my screen shot of the same NASDAQ 100.

https://drive.google.com/drive/folders/13XOHAGuDNjx6k98U5VB8AL2TmQOjyQqS?usp=sharing

Here's the Code to put in a Custom Column:
Code:
#uTS Watchlist Code for %52WkRng
#Mobius© WLC Percent Inside 52 Week Range

def h = highest(high, 252);
def l = lowest(low, 252);
def x = (close - l) / (h - l);
plot r = round(x * 100, 0);

#4 lines is complete code#

Use whichever you would like! :)

Below is a scan that I came across that will pull the top 20% of Relative Strength stocks in a Scan of the S&P 500. After loading the scanned list, most were above the 75% line for the above chart's RS line. I also changed the inputs to 0 & 20 and the RS line on this chart was down on all on the list. I suggest scanning in S&P 100 or 500 to keep your list manageable. My thanks to Chris Baker.

Code:
# Scan - Price Rank in Range 80-100
# Edited by Markos to prove out scan for Relative Strength - Use is set for 1Yr-1Day Chart
# This Scan Tab study finds stocks whose price is in the given Price Rank (Price Percentile)
# in the given number of bars.
# By Chris Baker <[email protected]> @ChrisBaker97
# Latest version maintained at: https://bitbucket.org/ChrisBaker97/thinkscript/src/
# This thinkScript is designed for use in the Scan tab. Detailed
# instructions may be found at: https://bitbucket.org/ChrisBaker97/thinkscript/
#
# This work is licensed under the Creative Commons Attribution-ShareAlike
# 3.0 Unported License. To view a copy of this license, visit:
# http://creativecommons.org/licenses/by-sa/3.0/deed.en_US

#Start Code
input period = 252;
input prLo = 80;
input prHi = 100;

def hi = highest(high,period);
def lo =  lowest(low,period);
def range = hi - lo;

def priceRank = 100 * (open - lo) / range;

plot inRange = prLo <= priceRank and priceRank <= prHi;
#End Code

Hi I'm not a coder. this looks wonderful but it seems I don't know how to add it well. I placed both scripts under custom in the scan tab. Are they to be used to scan separately ot together? If done together I get the same list as when done separately with the scan code. The watch list gives a different list and none of both scripts give a ranking column. Also I looked tru customize to see if I'm missing something. What am I missing? Aslo what is the time frame in terms of days? Is it just for current year or last 52weeks worth of working days or regular #days ? Please explain how to use this. Thanks
 
Last edited:
Thank you again for your efforts. I will look into your indicator.

My understanding of IBD's RS indicator is that we know (generally) how it works (weighting of last year RS by different time periods), but it then compares that performance vs other stocks in the index, which is maybe why there's a disconnect. So a 99 RS is outperforming the SP500 (or other equivalent index) by a greater magnitude than 99% of the other stocks in the index. So, if a ton of stocks are ****ing vs the market (like now), they still might have decent IBD RS since it's based on relative strength vs relative strength of other stocks (i.e. tallest dwarf in the room syndrome). I know not much about ThinkOrSwim, but if there's an array type function then maybe it's possible for it to rank the results? I'm mainly familiar with VBA and Excel, so I'm not sure. It's possible in there, anyways.

For right now I'm doing my purely technical scans in ToS and then exporting to Excel. I have a BAT file that downloads a bunch of IBD etables exports (not paying more than $16 for this info....) and merges them into one table in Excel. I then export the technical scan from TOS and it pulls all the fundamental info I want from the IBD reports and my filters then work from there. Takes about 1m to do now that I have it all set-up and linked, but not optimal.

But, I use the Mansfield RS (or the basic relative strength line works, too) in TOS simply to see if the RS is trending upwards. So, I'll filter out any stock in Excel that has RS less than 80 and from there re-import the list into TOS and go through to see if the RS is trending up or downards.
 
Ok, been jacking around with this for a bit and this is the O'neil ranking system I came up with. No way in hell is it the same as IBD but its nice on its own. Its another simple performance of 3,6,9,12 quarter with double weighting to first quarter. it then compares the sum of these 4 weighted returns to the absolute max return the stock could have made comparing highest to lowest. This is essentially how o'neil said it was set up on his site

o'neil explanation

When you put this next to some of the other ranking systems you have you'll notice it does NOT come close a lot of the time. It seveeerely punishes stocks that haven't kept holding an efficient trend for the year. Chopping won't cut it with this so it's a nice tool to have if you want stocks with predictability. This double weighted last quarter obliterated the ranking on quite of few of these it looks like. Definitely worth taking a look at for longer term traders IMO


Code:
#    O'Neil price performance RS ranking
#    WTF_Dude
#    5.5.20
#    color styling codes from #WLC_RS1Yr RS_Rank by GHorschman
#     `
#    RS_Rank > 80       -- Dark Green
#    80 <= RS_Rank < 60 -- Light Green
#    60 <= RS_Rank < 40 -- Gray
#    40 <= RS_Rank < 20 -- Light Red
#    RS_Rank <= 20      -- Dark Red
######################################################################

# Set length to period of interest.

#  1 Wk – 5 trading days
#  1 Mos – 21 Days
#  3 Mos – 63 Days
#  6 Mos – 126 Days
#  12 Mos – 252 Days

def year = if close-close[252] is less than 0 then 0 else close-close[252] ;
def nine =  if close-close[189] is less than 0 then 0 else close-close[189] ;
def six =  if close-close[126] is less than 0 then 0 else close-close[126] ;;
def three = if close-close[63] is less than 0 then 0 else close-close[63] ;;
def weighted = if ((2*three) + six + nine + year)/4 is less than 0 then 0 else ((2*three + six + nine + year)/4); #decimal

def h = highest(high, 252);
def l = lowest(low, 252);
def hilo = absvalue(h-l);
def calc = weighted/ hilo;

plot rsrank = round(100* calc,0);
#addlabel (yes,RSRank);

#AddLabel (yes, if  RSRank >= 1 and RSRank < 100 then "000" + astext(RSRank) else astext( RSRank)   );

assignbackgroundcolor (if RSRank > 80 then color.dark_green else
                       if RSRank > 60 and RSRank <= 80 then createcolor(0,175,0) else
                       if RSRank > 40 and RSRank <= 60 then color.gray else
                       if RSRank > 20 and RSRank <= 40 then CreateColor(220, 0,0) else
                       if RSRank <= 20 then CreateColor(150, 0,0) else
                       color.white);

Hi added this code to custom in the scan tab. Looks good but mine does not include a column for rank. What am I missing to do? Thanks
 
Hi added this code to custom in the scan tab. Looks good but mine does not include a column for rank. What am I missing to do? Thanks
It was made as a watchlist column, not a scan code. So just put the code as is in one of the custom slots on your WL and it should show up, then you just sort the rank.
 
Ok, it's the End of October! 🥳 Here is a share link to 5 Different Relative Strength Indicators that also includes my watchlist setup.
https://tos.mx/xCZKBN9

Below the picture are the codes for the individual columns.
For those that will test this, please give it a good workout and provide feedback on the column that works best for you.

@BenTen @mc01439 @Hguru @skynetgen @korygill @dougn @diazlaz @Shinthus @MBF @netarchitech @arthurx @Nick
Apologies to anyone I missed.

UkTrpO2h.jpg

Here are the 5 Relative Strength Studies in the Picture Above:

Column #1:

%CTM - Chande Trend Meter is a Scan, Column, and Lower Study. https://tos.mx/az08ZJg This can be found in school.stockcharts.com

Code:
# %CTM_Chande_Trend_Meter Scan ported in TSL by Mobius per request
#declare lower;
def h = high;
def l = low;
def c = close;
script Scale {
    input c = close;
    input Min = 0;
    input Max = 100;
    def hh = HighestAll(c);
    def ll = LowestAll(c);
    plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;
}
script BB
    {
    input price = close;
    input length = 20;
    def avg = Average(price, length);
    def sd = StDev(price, length);
    def upperBand = avg + (2 * sd);
    def lowerBand = avg - (2 * sd);
    plot PercentB = (price - lowerBand) / (upperBand - lowerBand) * 10;
}
def BB20H = BB(h, 20);
def BB20L = BB(l, 20);
def BB20C = BB(c, 20);
def BB50H = BB(h, 50);
def BB50L = BB(l, 50);
def BB50C = BB(c, 50);
def BB75H = BB(h, 75);
def BB75L = BB(l, 75);
def BB75C = BB(c, 75);
def BB100H = BB(h, 100);
def BB100L = BB(l, 100);
def BB100C = BB(c, 100);
def zScore = ((c - Average(c, 100)) / StDev(c, 100)) * 10;
def RSI = RSI() / 10;
def PriceChannel = ((c - Lowest(l, 2)) / (Highest(h, 2) - Lowest(l, 2))) * 10;
def sum = BB20H + BB20L + BB20C + BB50H + BB50L + BB50C + BB75H + BB75L + BB75C + BB100H + BB100L + BB100C + zScore + RSI + PriceChannel;
plot CTM = scale(sum);
#plot "90" = if isNaN(c) then double.nan else 90;
#plot "80" = if isNaN(c) then double.nan else 80;
#plot "60" = if isNaN(c) then double.nan else 60;
#plot "20" = if isNaN(c) then double.nan else 20;
# End Code CTM

Column #2:
My Weighted RS Script https://tos.mx/mpjIxjA
Code:
#09:56 Dave_S: # October 9 2019 in TSL
# Hi markos: here's is your repaired script; It still throws complex code warning.
# 07:38 markos: Good Morning. I am attempting to create my own version of a RS Rating watchlist column that is weighted to the latest 3 months.  This little code throws a complex script warning. What can be done to simplify it? Loooking for suggestions. Thanks!
#MYexpRS3 by Markos chgd title to RSwQH3qY 10-2019
#The idea here is a hack to create a Weighted Relative Strength per the math in Def Data2.

#declare lower;

input lengthYR = 252;
input length3QTRs = 189;
input lengthHalfYr = 126;
input lengthQTR = 63;
input lengthWk = 6;
input mid = 50;

  def C252 = Average(close, lengthYR);
  def C189  = Average(close, length3QTRs);
  def C126  = Average(close, lengthHalfYr);
  def C63  = Average(close, lengthQTR);
  def C6 = Average(close, lengthWk);

# def Data1 = close / close("ITOT");
def Data1 = close / Average(close, 6);
# def Data2 = (((2*(c/c63))+(1.25*(c/c126))+(c/c189)+(0.75*(c/c252)))/4);
def Data2 = (((2*(close/c63))+(1.00*(close/c126))+(0.75*(close/c189))+(0.50*(close/c252)))/4);
#def Data2 = (((5*(close/c63))+(3.00*(close/c126))+(1.00*(close/c189))+(0.25*(close/c252)))/4);
def Data3 = Data1 * Data2;
def newRngMin = 1;
def newRngMax = 100;
def HHData3 = HighestAll( Data3);
def LLData3 = LowestAll( Data3 );
plot nr = ((( newRngMax - newRngMin ) * ( Data3 - LLData3 )) / ( HHData3 - LLData3 )) + newRngMin;
#plot midline = mid;
#End MyexpRS3 Markos chgd title to RSwQH3qY 10-2019

Column #3:
https://tos.mx/f8FS7hd RS 6 Month Column

Code:
#WLC_RS6mo
#RS_Rank - 8/28/2019 Developed by GHorschman  ([email protected])
#######################################################################
# This is a custom quote to compute the Relative Strength percentile.
# It is calculated the same way that IV_Percentile is computed.  Just
# change the length to specify the time frame of interest.  The
# background color is tied to the following ranges:
#
#    RS_Rank > 80       -- Dark Green
#    80 <= RS_Rank < 60 -- Light Green
#    60 <= RS_Rank < 40 -- Gray
#    40 <= RS_Rank < 20 -- Light Red
#    RS_Rank <= 20      -- Dark Red
######################################################################

# Set length to period of interest.

#  1 Wk – 5 trading days
#  1 Mos – 21 Days
#  3 Mos – 63 Days
#  6 Mos – 126 Days
#  12 Mos – 252 Days

def length = 126;

#def RS = if IsNan(relativeStrength("SPX")) then 0 else relativeStrength("SPX") ;
def RS = RelativeStrength ("ITOT");
def RSLow = Lowest(RS, length);
def RSHigh = Highest(RS, length);
def RSRank = round(100 * (RS - RSLow) / (RSHigh - RsLow),0);
addlabel (yes,RSRank);

#AddLabel (yes, if  RSRank >= 1 and RSRank < 100 then "000" + astext(RSRank) else astext( RSRank)   );

assignbackgroundcolor (if RSRank > 80 then color.dark_green else
                       if RSRank > 60 and RSRank <= 80 then createcolor(0,175,0) else
                       if RSRank > 40 and RSRank <= 60 then color.gray else
                       if RSRank > 20 and RSRank <= 40 then CreateColor(220, 0,0) else
                       if RSRank <= 20 then CreateColor(150, 0,0) else
                       color.white);
#End Code

Column #4:
https://tos.mx/BNYLITs RS 12 month Script

Code:
#WLC_RS1Yr
#RS_Rank - 8/28/2019 Developed by GHorschman  ([email protected])
#####################################
# This is a custom quote to compute the Relative Strength percentile.
# It is calculated the same way that IV_Percentile is computed.  Just
# change the length to specify the time frame of interest.  The
# background color is tied to the following ranges:
#
#    RS_Rank > 80       -- Dark Green
#    80 <= RS_Rank < 60 -- Light Green
#    60 <= RS_Rank < 40 -- Gray
#    40 <= RS_Rank < 20 -- Light Red
#    RS_Rank <= 20      -- Dark Red
######################################

# Set length to period of interest.

#  1 Wk – 5 trading days
#  1 Mos – 21 Days
#  3 Mos – 63 Days
#  6 Mos – 126 Days
#  12 Mos – 252 Days

def length = 252;

#def RS = if IsNan(relativeStrength("SPX")) then 0 else relativeStrength("SPX") ;
def RS = relativeStrength("ITOT"); #SPX is default
def RSLow = Lowest(RS, length);
def RSHigh = Highest(RS, length);
def RSRank = round(100 * (RS - RSLow) / (RSHigh - RsLow),0);
addlabel (yes,RSRank);

#AddLabel (yes, if  RSRank >= 1 and RSRank < 100 then "000" + astext(RSRank) else astext( RSRank)   );

assignbackgroundcolor (if RSRank > 80 then color.dark_green else
                       if RSRank > 60 and RSRank <= 80 then createcolor(0,175,0) else
                       if RSRank > 40 and RSRank <= 60 then color.gray else
                       if RSRank > 20 and RSRank <= 40 then CreateColor(220, 0,0) else
                       if RSRank <= 20 then CreateColor(150, 0,0) else
                       color.white);
#End Code

Column #5:
https://tos.mx/dqmp2K1 This was the iteration from page 1. It is Percent Inside 52 week range.

Code:
# Mobius© WLC Percent Inside 52 Week Range
def h = highest(high, 252);
def l = lowest(low, 252);
def x = (close - l) / (h - l);
plot r = round(x * 100, 0);
#End Code

Please try out and see what works for you on your time frame!

Any one has tried out all 5 RS indicators above? Which one is the closest to IBD RS rating?
 
Any one has tried out all 5 RS indicators above? Which one is the closest to IBD RS rating?
They're all great as purely technical, but I looked more into it and the IBD ratings include fundamental variables too. EPS growth 30%yoy, 30%qoq, sales 30%, high ROE, etc etc etc. So none of them really
 
It was made as a watchlist column, not a scan code. So just put the code as is in one of the custom slots on your WL and it should show up, then you just sort the rank.

Yes, it added the column for rank but didn’t give me numbers instead it says, “Custom expression subscription limit exceeded.” I have only used 3 of my 19 custom slots so what does this mean? Also help, it seems that I need to customize the code because it says,


# Set length to period of interest.

# 1 Wk – 5 trading days


And since I want a week, I added these 2 lines. Did I do that right?

def week = if close-close[5] is less than 0 then 0 else close-close[5] ;

input length = 5 days;



and what do I enter for hi and lo?


def h = highest(high, 21);

def l = lowest(low, 21);

Shouldn’t hi and lo be a different number?
Thanks for your help.
 
@soary I think you are supposed to choose the 'Wk" from the pull down selection just to the right of where you type in the name for the custom column you just created. No need to edit or modify the body of the code itself. Just above the thinkScript Editor box that you select to be able to paste in the code.
 
@soary I think you are supposed to choose the 'Wk" from the pull down selection just to the right of where you type in the name for the custom column you just created. No need to edit or modify the body of the code itself. Just above the thinkScript Editor box that you select to be able to paste in the code.

Wonderful one of my 3 questions answered. Tthank you. Does it make sense that the hi/lo in the code is the same number of days or am I supposed to change it to something else and what that could be? It seems like they would cancel out if they are the same number of days.
[]]
p[\
 

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
304 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