IBD Stock Charts Style and Scan for ThinkorSwim

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 by a moderator:
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
 
"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.
 
@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 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.
 
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.
 
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
 
@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.
 
@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:
@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 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
 
@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:
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
 
@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:
@Bamilus thank you. May i know based on your criteria in your scan, can we say that those stocks that are scanned out will likely to have higher momentum and very trending? For me, i trade on daily time frame, and I hope to find a scan that helps me to find trending n momentum stocks. Will check our WTF_dude post as well.
 
@Bamilus thank you. May i know based on your criteria in your scan, can we say that those stocks that are scanned out will likely to have higher momentum and very trending? For me, i trade on daily time frame, and I hope to find a scan that helps me to find trending n momentum stocks. Will check our WTF_dude post as well.

Click my profile and read my posts - I explain everything.
 
When I add the relative strength indicator to my charts the indicator is in decimals but when I look at screenshots or videos from other users I see that the indicator is showing whole numbers. Image 1 is my indicator and image 2 is a screenshot from the thinkorswim learning center. How do I change this? I can't find where to change this when I edit the study.

oEXdjO7.png


3VreEaA.png
 

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