IBD Style Chart and Scan

B

Bamilus

New member
IBD RS rating doesn't include fundamentals, but their composite rating and other ratings do.
 
S

soary

Member
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.
 
R

RickAns

Member
@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.
 
S

soary

Member
@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[\
 
R

RickAns

Member
Just to be certain I believe we are talking about wtf_dude's code. It does make sense that the hi / lo numbers are the same. The look back period is a year, then the quarters are ranked against each other. With more concern given to the most recent quarter.

I am still new to coding so it took me to read it a few times to make sense. It does, but I may not be the best one to explain it to someone else. This uses a one year time frame 252 trading days that's a given. What we are setting (I believe) with day / week / month is just a small window or snapshot of what the data ranking is for the current most recent day/ week/ etc. Try not to think of it as setting (for example) a time period of a moving average or whatever.

I can delete my example if completely wrong in order to avoid further confusion. :oops:


Added:
By changing the hi /lo to 21 in your example post instead of the original 252 you have told the code to look back only 21 days max instead of a year. Preventing you from getting the stock's high and low of the year. So you are only getting a ranking for the last month's worth of data.

Does this help?
 
Last edited:
wtf_dude

wtf_dude

Active member
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.
Ok, first question: custom subscription exceeded means you have too many advanced calculations going on and TOS doesn't wanna do any more for ya basically haha. I really never looked into if its a RAM thing or if iits just because real money runs through different servers. SOMETIMES you'll get that message on the real money side and not on the paper money side. May want to check to see if it works over there first. If it does, it's a server thing most likely.

Next, I can't really tell what youre trying to do? Are you trying to just do like day and month?

Next question. The high and low expression, you just put the longest time frame you want to check. What that code does is find the all the time high within that many days, and the lowest low of that many days. You don't need to change anything but timeframe for the search
 
S

soary

Member
"Next question. The high and low expression, you just put the longest time frame you want to check. What that code does is find the all the time high within that many days, and the lowest low of that many days. You don't need to change anything but timeframe for the search:"

Ok, first question: custom subscription exceeded means you have too many advanced calculations going on and TOS doesn't wanna do any more for ya basically haha. I really never looked into if its a RAM thing or if iits just because real money runs through different servers. SOMETIMES you'll get that message on the real money side and not on the paper money side. May want to check to see if it works over there first. If it does, it's a server thing most likely.

Next, I can't really tell what youre trying to do? Are you trying to just do like day and month?

Next question. The high and low expression, you just put the longest time frame you want to check. What that code does is find the all the time high within that many days, and the lowest low of that many days. You don't need to change anything but timeframe for the search

wtf_dude aaaaha! I get it now. it makes sense why the numbers of days is the same. lol Thank you for your patience and answering my questions. I learned a lot with this thread. I'll find out from TOS what that msg is all about

RickAns thank you for your help, it was nice of you.
 
A

Art

Member
@wtf_dude question for you. When I add your script to my chart, my entire chart's background turns from dark to red. What am I doing wrong/missing? Thanks
 
wtf_dude

wtf_dude

Active member
@wtf_dude question for you. When I add your script to my chart, my entire chart's background turns from dark to red. What am I doing wrong/missing? Thanks
It's not a code made for a chart, its made for a watchlist column for sorting. It's turning red because the code assigns a background color to each "box" on a watchlist based on value.
 
R

RickAns

Member
@Art I made that mistake too. Then I re-read the part about it being for the watchlist column and not the chart. :giggle:

I'm liking this code, thanks @wtf_dude .
 
S

sfs00784

New member
Relative Price Strength (RS) Rating or Relative Strength [official]
This IBD SmartSelect Corporate Rating is a measure of a stock’s price performance over the last twelve months, compared to all stocks in our database. A 40% weight is assigned to the latest three-month period; the remaining three quarters each receive 20% weight. The rating scale ranges from 1 (lowest) to 99 (highest). Initial Public Offering (IPO) stocks will be assigned a "1" rating until the data from five trading sessions are available for calculation.

The formula I saw is this for RS: [from a forum]
.4TR13weeks*.2TR26weeks*.2TR39weeks*.2TR52weeks
TR=total return.

Anyone can write a line to test it?
I am new to this.
 
A

Art

Member
Hi @markos, I was playing with your Column #3 and 4 - 6 months and 12 months columns and wanted to see if I can incorporate it with my strategy. I would appreciate it if you can shed some light on this issue. I just want to make sure I'm getting it right.

I added the script as an indicator to my charts(not as a column) - I'm running it on daily, 4hr, and 1hr for my entries. I see a label on the daily chart and I'm assuming that's the daily RS score. Am I right?

Then I add the same script to my 90 days 1 hr and 180 days 4 hr charts and change the def length to 63 and 126 accordingly I get N/A. But when I add the same code with the def length 63 or 126 to the daily chart I get another score and I'm assuming that's the RS score for 3 and 6 months. Is this the right logic?

Best,
Art
 
markos

markos

Well-known member
VIP
@Art I'm not quite sure... ps I'll be "awol" for a while again. I wasn't happy with any of the RS codes that I played with. You're right about it being the score on the daily. Try a different thought, TOS has a new built in called RSMK which will work as a lower and can also be a WLC. It should also work with addLabel(). I use it in my watchlist as well as on my chart. Sorry I can't help further.
 
markos

markos

Well-known member
VIP
@Art @Nick @diazlaz @BenTen @wtf_dude @RickAns @soary @horserider @dougn @korygill @mc01439 and the rest of the world!!

Only here for a quick note. Mike Webster, the longest tenured Portfolio Manager at IBD/MarketSmith was on a video I saw over the weekend. (Sorry, I don't know which one) He stated that even though in IBD the RS line is based off of 1 year, he no longer uses it. When he helped build MarketSmith, it bothered him that Qualcom, during the 2000 Dot Com crash, had an RS in the 90's after it crashed. The reason was that it ran up 35 fold the previous year and after the crash was still ahead of over 90% of the stocks in the Database. The lesson was that everything needs to be looked at in context. He is now using a shorter timeframe and formula that is proprietary to IBD/MarketSmith.

Next, TraderLion dot com, which is run by a former Portfolio Manager at IBD, put out a guide to create the IBD RS Line in StockCharts dot com, for anyone interested in porting that to thinkorswim... Google might help...

Best wishes and good trading, Markos.
 
Last edited:
N

Nick

Active member
2019 Donor
VIP
@markos thank you for your sharing. This information came in so timely as i was deciding which RS indicator to use for my trading.
 
N

Nick

Active member
2019 Donor
VIP
@markos thank you for your sharing. This information came in so timely as i was deciding which RS indicator to use for my trading.
@markos this is what i have found....https://www.traderlion.com/technical-analysis/plotting-the-relative-strength-line-in-stockcharts/.....If there are anyone who can convert this to TOS,....it will be much appreciated..Thank you
 
B

Bamilus

New member
@markos this is what i have found....https://www.traderlion.com/technical-analysis/plotting-the-relative-strength-line-in-stockcharts/.....If there are anyone who can convert this to TOS,....it will be much appreciated..Thank you
Literally all he did was plot the relative strength vs SPY. This is a built in study in TOS: https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/R-S/RelativeStrength.

There is no way to replicate the IBD line accurately because it is a formula that takes the RS performance over last 52 weeks and then ranks it vs all other stocks. So, even if you're outperforming the SP500, your IBD RS could go down if you're not outperforming it as much as other stocks are. I've tried about 6 different formulas, some posted here and some from elsewhere, and none accurately can mimic the IBD RS line to a degree that is acceptable. You'll find that you can often mimic a majority of stocks with these formulas, but there will be large outliers for the ranking reasons I stated, above.

The best proxy I've seen is the Mansfield RS line which I've posted in other threads (see my post history). That indicator plots the difference between the relative strength line moving average and sets 0 to equal when the RS line equals it's 200 DMA. So, if a stock is increasing its rate of outperformance vs the SP500 (or whatever indicator you set it to compare to), its mansfield RS line will move up. This won't mimic IBD RS but it will mimic regular RS, but has the advantage of allowing you to scan for stocks with Mansfield RS over 0, which means their RS is currently above their RS 200 DMA, which will filter out a lot of low RS stocks. Any stock below it's 200 DMA RS will not have a high IBD RS rating (generally speaking. There are exceptions like if a stock has a huge 1 day drop, but you probably aren't looking to be buying those types of stocks if you're a growth investor).
 
Last edited:
N

Nick

Active member
2019 Donor
VIP
Literally all he did was plot the relative strength vs SPY. This is a built in study in TOS: https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/R-S/RelativeStrength.

There is no way to replicate the IBD line accurately because it is a formula that takes the RS performance over last 52 weeks and then ranks it vs all other stocks. So, even if you're outperforming the SP500, your IBD RS could go down if you're not outperforming it as much as other stocks are. I've tried about 6 different formulas, some posted here and some from elsewhere, and none accurately can mimic the IBD RS line to a degree that is acceptable. You'll find that you can often mimic a majority of stocks with these formulas, but there will be large outliers for the ranking reasons I stated, above.

The best proxy I've seen is the Mansfield RS line which I've posted in other threads (see my post history). That indicator plots the difference between the relative strength line moving average and sets 0 to equal when the RS line equals it's 200 DMA. So, if a stock is increasing its rate of outperformance vs the SP500 (or whatever indicator you set it to compare to), its mansfield RS line will move up. This won't mimic IBD RS but it will mimic regular RS, but has the advantage of allowing you to scan for stocks with Mansfield RS over 0, which means their RS is currently above their RS 200 DMA, which will filter out a lot of low RS stocks. Any stock below it's 200 DMA RS will not have a high IBD RS rating.
@Bamilus May i know if you use TOS to scan stocks with Mansfielf RS over 0? I am keen to learn how to scan for good momentum stocks and wonder if mansfield RS can fulfill the requirement. Thank you
 
B

Bamilus

New member
@Bamilus May i know if you use TOS to scan stocks with Mansfielf RS over 0? I am keen to learn how to scan for good momentum stocks and wonder if mansfield RS can fulfill the requirement. Thank you
Certainly, friend. Here is the custom study - call it what you want but I named it MansfieldDaily. WTF_dude (user here) posted a better version - search his history to find it. His version allows you to input the length and security. My version is just hardcoded since I always want 52 week (200 day) and SPX, but his is the better version. Regardless, they both show the same output.

Code:
declare lower;

input CorrelationWithSecurity = "SPX";
def SPXclose = close(CorrelationWithSecurity);
def R200 = close/SPXclose;


def RS_today = close / SPXclose;
def BSAverage = (sum(r200, 200)/200);
Plot RS2 = ((R200/BSAverage)-1)*10;
plot zeroline = 0;

RS2.SetDefaultColor(GetColor(6));plot Data = close;
In the scan, add a custom filter using Condition Wizard. See screenshot below for settings.

https://ibb.co/T4L9Xqn
 
Last edited:
Thread starter Similar threads Forum Replies Date
R IBD Distribution Days Study for TOS Questions 13
J Display symbol on chart? Questions 2
R Can TOS bet set up to detect complex chart patterns? Questions 2
O VWAP on Renko chart Questions 2
P Buy/Sell Chart Label Questions 3
Similar threads





Top