Financial Fundamentals Labels for ThinkorSwim

Updated The Analysis and Score For Fundamental Labels
the code in post#1 has been updated.

The biggest revision of this script is to the scoring of the Fundamentals. Originally the P/E was weighted so heavily that no stock w/ a negative P/E could get a score over the minimum threshold. Now, if a stock has positive profits / book ratios and/or positive debt/asset ratios, positive sales/share, good inventory turnover but a negative P/E that stock could possibly receive a good score. CommScope's fundamentals in the 1st post is a good example. CommScope has a negative P/E but otherwise some really interesting numbers.

Additional labels have been added for inventory turnover, book value, and a few more. I originally left these off because how to interpret them varies drastically by sector. But given that fundamentals analysis assumes a certain amount of in-depth understanding of the equity to start with, these can give breathe to that analysis.
HTH
 
Does anyone know how to script this so that the % change bubble pops up on earnings days? I've been trying to script it with some of the previous scrips posted on here but cant seem to get it, thanks!
 
Important fix and yield addition.
Added dividend yield and changed how payout is displayed. The dividend payout is the percentage of the earnings that are paid out as dividend. Previously this showed it as a dollar amount. Just delete and replace all of the dividend info/labels with this.

Code:
def DivPayout = if IsNaN(DividendPayout())
                then DivPayout[1]
                else DividendPayout();
AddLabel(show_labels and DivPayout, "Dividend Payout = " + round(DivPayout,2) + "%", GlobalColor("neutral"));

def DivPerShare = if IsNaN(DividendsPerShareTTM())
                  then DivPerShare[1]
                  else DividendsPerShareTTM();
AddLabel(show_labels and DivPerShare, "Dividend Per Share = " + AsDollars(DivPerShare), GlobalColor("neutral"));

def DivYield = if IsNaN(DividendsPerShareTTM())
                  then DivPerShare[1]
                  else DividendsPerShareTTM()/Close;
AddLabel(show_labels and DivPerShare, "Dividend Yield = " + AsPercent(DivYield), GlobalColor("neutral"));
 
Last edited:
Using stock hacker, I’m trying to use a custom column and adding a calculation

the script is

Plot Val = ReturnOnEquity() / close (“TYX”) * BookValuePerShare();


TYX being the 30 year treasury yield

the error says ‘ invalid symbol in Stock Fundamentals function’

I realize I’m not providing parameters to the functions but I get the same error even when I do

any help would be so appreciated, thanks
 
@57lp Welcome to UseThinkScript! Maybe try specifying the symbol for the fundamental functions, i.e. ReturnOnEquity(symbol = "SPY", fiscalperiod = fiscalperiod.year). Doing so removes the errors, have no idea if that would work for your purposes. Also, check if such functions even work in columns - I'm not certain if TOS allows fundamentals to be used there. I do know that portfolio functions can't be used in columns, so I wouldn't be surprised if fundamentals don't either.
 
@Pensar Thanks, I hardcoded a symbol in the script and that worked . That tells me the ReturnOnEquity and BookValuePerShare functions actually do work

phew, glad to know TOS has all those beautiful functions and they’re usable

All I need now is a proper way to reference the symbol on the current row as the script is processing . I’m starting to think getSymbol() doesn’t behave I think it should
 
@57lp Yes, it works with hard-coding in the symbol. But the fact that it can't retrieve the specific symbol data for each column line makes me think that those functions are not meant to be used in columns.
 
@57lp It isn't a bug. It seems to just be data that can only get accessed on a chart, not in a column. I think. I've tried to search for something more substantial than my suspicion, but this is all I can find - https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Stock-Fundamentals/ReturnOnEquity and https://tlc.thinkorswim.com/center/...unctions/Stock-Fundamentals/BookValuePerShare. The Thinkscript manual can be vague or missing information in some areas. Someone who has more experience with what can or can't be used in columns might be able to verify that.
 
Code:
Declare Lower;
input symbol1 = "TYX";
Input Length = 63;
Input Length2 = 126;
def Return_On_Equity = if IsNaN(ReturnOnEquity())
                       then Return_On_Equity[1]
                       else ReturnOnEquity();
def BookValue = if IsNaN(BookValuePerShare())
                then BookValue[1]
                else BookValuePerShare();
Def Factor = Close(symbol1);
Def ROE_BV = (Return_On_Equity/Factor)*BookValue;
Def ROE_BV_A = ExpAverage(ROE_BV,Length);
Def ROE_BV_A2 = ExpAverage(ROE_BV,Length2);
Plot A = ROE_BV;
Plot B = ROE_BV_A;
Plot B2 = ROE_BV_A2;
A.setDefaultColor(Color.Cyan);
B.setDefaultColor(Color.Magenta);
B2.setdefaultColor(Color.Red);
AddCloud(A,B,Color.Cyan,Color.Magenta);
AddCloud(B,B2,Color.Magenta,Color.Red);
A.SetLineWeight(2);
B.setLineWeight(2);
B2.setLineWeight(2);

The code works when plotted on a chart, but I fail to see how this brings any value to my trading? I tried to use EMA's to smooth and show crossings? I'm still dumbfounded as to how to interpret this ?
 
henrys study shows what code is needed for using the data on a chart. these functions only produce a value once in a few months or once a year. so you need a data source that goes back a year and once a valid number is read, it has to be passed on to the next bar.

ReturnOnEquity() , can be set to have a value as often as quarterly, 1 bar every 3 months.
BookValuePerShare() , can be set to have a value on 1 bar over a year.

i'm not sure if a scan study can find the most recent bar with a valid value, and then read the value itself?
 

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