Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Updated the ChandeTrendMeter charting to have clouds like stockcharts vs just lines. Looks very close but the formula must be a little different because the values arent an exact match. Works well enough from what I can tell@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
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);
def "90" = if isNaN(c) then double.nan else 90;
addCloud(90,100, color.dark_green, color.dark_green);
def "80" = if isNaN(c) then double.nan else 80;
addCloud(80,89, CreateColor(0, 153, 0), CreateColor(0, 153,0));
def"60" = if isNaN(c) then double.nan else 60;
addCloud(60,79, CreateColor(100,200,100), CreateColor(100,200,100));
def "20" = if isNaN(c) then double.nan else 20;
addCloud(21,59, CreateColor(225, 225,100), CreateColor(225, 225,100));
addCloud(0,20, color.dark_red, color.dark_Red);
# End Code CTM
There are many scan scripts in this thread.Anyone figure out how to make this into a scanner yet?
I found this code I believe in the Minervini VCP forum, i did fiddle a little with it and i scan for stocks with a 85 or better RS and most of the stocks are pretty close to IBD RS reports. I ad this to many of my scans to weed out some the more non favorable stocks. hope someone else can use itGave this a little bit more flexibility to be able to switch it to other numbers, securities, etc. Also, the multiplier was supposed to 100, not 10 like posted here. For some reason the indices are cutting off at the end of 2019, so I just switched it to spy for now.
Code:declare lower; input Correlation_with_Security = "SPY"; input length = 200; input Period = AggregationPeriod.DAY; input averagetype = AverageType.Simple; def price = close; def RSD = close/(close(correlation_with_security)); def RSDavg = MovingAverage(averagetype, RSD, length); plot RSM = (( RSD / RSDavg) - 1 ) * 100; plot zeroline = 0; zeroline.SetDefaultColor(GetColor(2));
#
#RS_Rank - 8/28/2019 Developed by GHorschman ([email protected])
#######################################################################
# ==============================================================================
# SMO_RsRank.ts: TOS script mimicking IBD Relative Strength Rank
# Version 1: 2021-01-24
# Calculated according to the following principles:
# The Relative Strength Rating is the result of calculating a stock’s
# percentage change of prices over the last 4 quarters:
# A 40% weight is assigned to the latest quarter period;
# the remaining three quarters each has 20% weight.
# The stock's price performance is compared w/ a general market index
# (e.g.SPX) to generate relative strength.
# It's intended to rate stocks in order of greatest price performance
# and assigned a percentile rank from 99 (highest) to 1 (lowest). A 50% rank
# indicates same price performance as the general market index.
#
# Two step usage procedure:
# 1). Get calibrated data first
# Create a custom scan by copying the code from the beginning to the
# the section marked as "End of Scan Code Section"
# Need to add a custom quote named as "IBD_RS" for sorting top and
# bottom scores
# 2). Input calibrated data
# Put the obtained data to the variables defined below the section
# named "Multipoint Calibration"
# There are 3 data points for this version and may be updated weekly
# or monthly, depending on your trading time frame.
# The prices used here are close prices and the quarter may be calendar
# quarter or other number of days if shorter term ranking is desired.
#==============================================================================
script my_rsrank {
# Set length to period of interest.
# Only total length of days is input and other periods are derived
input len4 = 252;
input cl = Close;
def len1 = round(len4/4, 0); #63;
def len2 = len1 * 2; #126;
def len3 = len1 * 3; #189
# Calculate price change percentages per quarter
def p4q = (cl[len3]-cl[len4]) / cl[len4];
def p3q = (cl[len2]-cl[len3]) / cl[len3];
def p2q = (cl[len1]-cl[len2]) / cl[len2];
def p1q = (cl-cl[len1]) / cl[len1];
def weighted = ((2*p1q) + p2q + p3q + p4q) / 5;
plot rsrank = 99 * weighted;
}
# 1 Wk – 5 trading days
# 1 Mos – 21 Days
# 3 Mos – 63 Days
# 6 Mos – 126 Days
# 12 Mos – 252 Days
def len4 = 252;
# Use the following for 6 month period ranking
#def len4 = 126;
def stockCl = close;
def indexCl = close("SPX");
def stock_rsrank = my_rsrank(len4, stockCl);
#plot stockdbg = stock_rsrank;
def index_rsrank = my_rsrank(len4, indexCl);
#plot indexdbg = index_rsrank;
def index_rsrank1 = if (index_rsrank == 0, index_rsrank[1], index_rsrank);
def RS = stock_rsrank/index_rsrank1;
#------------------- Code required for Custom Quote in Scan Tab----------------
#Selectively uncomment the following code in scan tab
# The following RS scores as of today need to be adjusted in each periodical
# calibrations
# Possible RS scores for bottom 1%
#input rs_score = -1;
#Possible RS scores for top 1%
#input rs_score = 4.5;
# Possible RS scores for top 10%
input rs_score = 2.8;
plot scan = if rs_score <= 0 then rs < rs_score else
rs > rs_score;
#---------------- End of Scan Code Section ------------------------------------
# Uncomment the following if display of relative strength is required
# Please select the option of left axis for this indicator
#plot rsCurve = rs;
#-------------------- Multipoint Calibration ----------------------------------
# Get the max & min values of RS for the reference index_rsrank (e.g. SPX)
# by using the TOS scan /w customized quote IBD_RS and sorting the results
# Max value is the min rs value of the top 5 (1%) stocks in the SP 500
# Min value is the max rs value of the bottom 5 (1%) stocks in the SP 500
# The calibration should be done weekly or at other time as necessary
# Replace the values below with the values obtained from custom quote
# RS score corresponding to 99 percentile
def HHData = 6.1;
# RS score corresponding to 1 percentile
def LLData = -1.1;
# Add a 90% calibration point since we are very interested at this percentile
# The RS score should be the score of top n'th stock,
# where n is the Total number of Index Stocks (e.g. 505 for SPX) x (100% - 90%)
# (e.g. 51 for SPX)
def d90 = 2.91;
#------------------- End of Calibration Data -----------------------------------
# For SPX & SPY, the RS score should be 1 and correlate to a 50 percentile rank
def d50 = 1;
def rsCalibrated = if rs > HHData then HHData else
if rs < LLData then LLData else
RS;
#plot dbgCal = rsCalibrated;
# Create final RS rank /w multiple point calibrated segments
# Formula for each segment:
# Segment RS Rank = [(End RS Rank - Start RS Rank) * (RScalibrated - Start RS)) /
# (End RS - Start RS)] + Start RS Rank
#plot nr = # Segment: Start Rank: 1, End Rank: 50
# if rsCalibrated <= 1 then
# (( 49 * ( RScalibrated - LLData )) / ( d50 - LLData )) + 1
# else
# Segment: Start Rank: 51, End Rank: 90
# if rsCalibrated <= d90 then
# (( 39 * ( RScalibrated - d50 )) / ( d90 - d50 )) + 51
# Segment: Start Rank: 91, End Rank: 99
#else
# (( 8 * ( RScalibrated - d90 )) / ( HHData - d90 )) + 91;
#nr.hide();
# Color coding from top to bottom ranks:
# Bright Green -> Dark Green -> Grey -> Dark Red -> Bright Red
#AddLabel(yes, Concat("RS Ranking: ", round(nr, 0)),
# if nr > 85 then color.green else
# if nr > 71 and nr <= 85 then color.Lime else
# if nr > 20 and nr <= 70 then color.red else
# color.red) ;
# End of Code
The IBD Top 50 is proprietary. It is not available to the ToS appDoes anyone know any code to put the IBD top 50 in your watchlist or can you subscribe to it and get the code from Investor's Business Daily?
I moved your post here. You will find 8 pages of rs rank scripts. Plug&Playany body has script for relative strength indicator for SPY vs stock?
If you have tc2000, you open FFTY and four lines next to that symbol, click on it, and you can open up the component list of IBD 50.The IBD Top 50 is proprietary. It is not available to the ToS app
can you access the IBD 50 in TC2000 without a subscription to IBD?If you have tc2000, you open FFTY and four lines next to that symbol, click on it, and you can open up the component list of IBD 50.
Yes, pull up the symbol FFTY, click on the right of the symbil four lines, and the component list ofcan you access the IBD 50 in TC2000 without a subscription to IBD?
in TOS we can go to the analyze tab then fundamentals tab and type in a ETF symbol and we get all the holdings within that ETF, unfortunately it does not show the FFTY holdings, maybe if enough people request it we can get it some dayYes, pull up the symbol FFTY, click on the right of the symbil four lines, and the component list of
IBD 50 is there. The list of components changes in FFTY weekly....??
in the twitter link can see how the component list works, it just doent show the FFTY list
I do not know anything about the above website and cannot attest to the veracity of its information or why its IBD 50 csv file contains 100 stocks.The Innovators IBD 50 ETF - FFTY holdings are available directly from Innovator's website at https://www.innovatoretfs.com/etf/?ticker=ffty&ticker=ffty#holdings
Start a new thread and receive assistance from our community.
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.
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.