Join useThinkScript to post your question to a community of 21,000+ developers and traders.
TOS is a nice platform, but the scan hacker needs work!Fundamentals can not be used in a custom scan script. They can only be used in the ToS Scan Hacker in a limited manner.
As shown here:
https://usethinkscript.com/threads/...or-basic-fundamental-analysis.866/#post-49702
It has to do with the format that the data provider feeds the information.TOS is a nice platform, but the scan hacker needs work!
Thank you for the response, I will look around and see if I can find something. I have been using Marketsmith to find the combination of technical and fundamental strength, but if I can save $1500 a year and get some close to the same results scanning on a free platform then im all for it.It has to do with the format that the data provider feeds the information.
If you have a script from another platform that has found a workaround to the issue, we could use that logic to jerry-rig something for ToS.
I also pay for a service to collect the data that is not available on the platform.Thank you for the response, I will look around and see if I can find something. I have been using Marketsmith to find the combination of technical and fundamental strength, but if I can save $1500 a year and get some close to the same results scanning on a free platform then im all for it.
Also i do not see the weighted score you mention above. Do I need to turn something on?This indicator displays fundamental data of a stock, including financial info such as Free Cash Flow, Profit Margin, etc., on your chart.
An overall weighted Score is calculated to gauge the overall financial health
Hello @MerryDay, bit of a silly question, but are there a certain set or number of labels turned green that you look for before digging further to determine if a trade is applicable?Use on a Daily Chart. Useful for anyone interested in fundamental stock research.
Ruby:#Fundamental Data Labels _Mobius 4/26/20 (found on OneNote) # # @MerryDay revised 4/21: # my interpretation of positive/negative values; should be modified to meet your strategy # then calculated an overall weighted score based on: # https://tradestation.tradingappstore.com/products/FundamentalScore/document/Fundamental_Score.pdf # and other information found on the web declare lower; declare hide_on_intraday; input show_labels = yes ; input show_summaries = no ; DefineGlobalColor("Pre_Cyan", CreateColor(50, 200, 255)) ; DefineGlobalColor("LabelGreen", CreateColor(0, 165, 0)) ; DefineGlobalColor("LabelRed", CreateColor(225, 0, 0)) ; DefineGlobalColor("Violet", CreateColor (200, 125, 255)) ; DefineGlobalColor("GrayGreen", CreateColor(155, 167, 76)) ; DefineGlobalColor("LitePink", CreateColor (220, 180, 180)) ; DefineGlobalColor("neutral", color.light_gray) ; def fp = FiscalPeriod.YEAR; def EPS = EarningsPerShareTTM(fiscalPeriod = fp); def PE = round(close / EPS,1); AddLabel(show_labels and PE, "P/E ratio = " + Round(PE, 2), if PE < 0 then GlobalColor("LitePink") else if PE < 20 then GlobalColor("LabelGreen") else if PE < 40 then GlobalColor("GrayGreen") else GlobalColor("Pre_Cyan")); def EarnPerShare = if IsNaN(EarningsPerShareTTM()) then EarnPerShare[1] else EarningsPerShareTTM(); AddLabel(show_labels and EarnPerShare, "EPS-TTM = " + AsDollars(EarnPerShare), if EarnPerShare > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def FreeCashFlowPerSh = if isNaN(FreeCashFlowPerShare()) then FreeCashFlowPerSh[1] else FreeCashFlowPerShare(); AddLabel(show_labels and FreeCashFlowPerSh, "Free Cash Flow Per Share = " + AsDollars(FreeCashFlowPerSh), if FreeCashFlowPerSh > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_EarnCash = if PE <0 and FreeCashFlowPerSh < 0 and EarnPerShare < 0 then 0 else 5; def Gross_Profit_Margin = if IsNaN(GrossProfitMargin()) then Gross_Profit_Margin[1] else GrossProfitMargin(); AddLabel(show_labels and Gross_Profit_Margin, "Gross Profit Margin = " + Round(Gross_Profit_Margin, 2), if Gross_Profit_Margin > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def Operating_Profit_Margin = if IsNaN(OperatingProfitMargin()) then Operating_Profit_Margin[1] else OperatingProfitMargin(); AddLabel(show_labels and Operating_Profit_Margin, "Operating Profit Margin = " + Round(Operating_Profit_Margin, 2), if Operating_Profit_Margin > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def Net_Profit_Margin = if IsNaN(NetProfitMargin()) then Net_Profit_Margin[1] else NetProfitMargin(); AddLabel(show_labels and Net_Profit_Margin, "Net Profit Margin = " + Round(Net_Profit_Margin, 2), if Net_Profit_Margin > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_Profits = if Gross_Profit_Margin>0 or Net_Profit_Margin>0 or Operating_Profit_Margin > 0 then 3 else 0 ; def CurRatio = if IsNaN(CurrentRatio()) then CurRatio[1] else CurrentRatio(); AddLabel(show_labels and CurRatio, "Current Ratio = " + Round(CurRatio, 2), if CurRatio > 2 then GlobalColor("GrayGreen") else if CurRatio >= 1 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def Quick_Ratio = if IsNaN(QuickRatio()) then Quick_Ratio[1] else QuickRatio(); AddLabel(show_labels and Quick_Ratio, "Quick Ratio = " + Round(Quick_Ratio, 2), if Quick_Ratio > 2 then GlobalColor("GrayGreen") else if Quick_Ratio >= 1 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_Ratios = if Quick_Ratio >= 1 or CurRatio >= 1 then 3 else 0; def Return_On_Assets = if IsNaN(ReturnOnAssets()) then Return_On_Assets[1] else ReturnOnAssets(); AddLabel(show_labels and Return_On_Assets, "Return On Assets = " + Round(Return_On_Assets), if Return_On_Assets >= 15 then GlobalColor("Pre_Cyan") else if Return_On_Assets >= 10 then GlobalColor("LabelGreen") else if Return_On_Assets > 0 then GlobalColor("GrayGreen") else GlobalColor("LitePink")); def Return_On_Equity = if IsNaN(ReturnOnEquity()) then Return_On_Equity[1] else ReturnOnEquity(); AddLabel(show_labels and Return_On_Equity, "Return On Equity = " + Round(Return_On_Equity), if Return_On_Equity >= 15 then GlobalColor("Pre_Cyan") else if Return_On_Equity >= 10 then GlobalColor("LabelGreen") else if Return_On_Equity > 0 then GlobalColor("GrayGreen") else GlobalColor("LitePink")); def score_Returns = if Return_On_Equity >= 10 or Return_On_Assets >=10 then 1 else 0 ; def Sales_Per_Share = if IsNaN(SalesPerShare()) then Sales_Per_Share[1] else SalesPerShare(); AddLabel(show_labels and Sales_Per_Share, "Sales Per Share = " + Round(Sales_Per_Share, 2), if Sales_Per_Share > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_Sales_Per_Share = if Sales_Per_Share > 0 then 1 else 0; def FixChgCovRatio = if IsNaN(FixedChargeCoverageRatio()) then FixChgCovRatio[1] else FixedChargeCoverageRatio(); AddLabel(show_labels and FixChgCovRatio, "Fixed Charge Coverage Ratio = " + Round(FixChgCovRatio, 2), if FixChgCovRatio >= 1 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def Total_Asset_Turnover = if IsNaN(TotalAssetTurnover()) then Total_Asset_Turnover[1] else TotalAssetTurnover(); AddLabel(show_labels and Total_Asset_Turnover, "Total Asset Turnover = " + Round(Total_Asset_Turnover, 2), if Total_Asset_Turnover > 1 then GlobalColor("LabelGreen") else GlobalColor("neutral")); def FinLev = if IsNaN(FinancialLeverage()) then FinLev[1] else FinancialLeverage(); AddLabel(show_labels and FinLev, "Financial Leverage = " + Round(FinLev, 2), if FinLev > 0 and FinLev < 2 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_FinLev = if FinLev < 2 then 1 else 0; def BookValue = if IsNaN(BookValuePerShare()) then BookValue[1] else BookValuePerShare(); AddLabel(show_labels and BookValue, "Book Value Per Share = " + Round(BookValue), if BookValue < 2 then GlobalColor("Pre_Cyan") else if BookValue < 3 then GlobalColor("LabelGreen") else GlobalColor("neutral")); def Long_Term_Debt_To_Capital = if IsNaN(LongTermDebtToCapital()) then Long_Term_Debt_To_Capital[1] else LongTermDebtToCapital(); AddLabel(show_labels and Long_Term_Debt_To_Capital, "Long Term Debt To Capital = " + Round(Long_Term_Debt_To_Capital, 2), if Long_Term_Debt_To_Capital < 5 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_Long_Term_Debt_To_Capital = if Long_Term_Debt_To_Capital < 5 then 1 else 0; def Inventory_Turnover = if IsNaN(InventoryTurnover()) then Inventory_Turnover[1] else InventoryTurnover(); AddLabel(show_labels and Inventory_Turnover, "Inventory Turnover = " + Round(Inventory_Turnover, 2), if Inventory_Turnover < 5 then GlobalColor("LitePink") else if Inventory_Turnover < 10 then GlobalColor("Pre_Cyan") else if Inventory_Turnover < 15 then GlobalColor("GrayGreen") else GlobalColor("LitePink")); 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")); def Interest_Rate = if IsNaN(InterestRate()) then Interest_Rate[1] else InterestRate(); AddLabel(show_labels and Interest_Rate, "Interest Rate = " + Round(Interest_Rate, 2), GlobalColor("neutral")); def Tax_Rate = if IsNaN(TaxRate()) then Tax_Rate[1] else TaxRate(); AddLabel(show_labels and Tax_Rate, "Tax Rate = " + Round(Tax_Rate, 2), GlobalColor("neutral")); plot score = score_Returns + score_EarnCash + score_ratios + score_Profits + score_FinLev + score_Sales_Per_Share + score_Long_Term_Debt_To_Capital; AddLabel(show_summaries, "SCORE: " + score, if score >= 12 then GlobalColor("Pre_Cyan") else if score >= 10 then GlobalColor("LabelGreen") else if score >= 8 then GlobalColor("GrayGreen") else GlobalColor("LitePink")); score.hide();
Thanks for the heads up... I didn't realize when I posted the latest version, that I mistakenly hid 'score'Also i do not see the weighted score you mention above. Do I need to turn something on?
Hello @MerryDay, bit of a silly question, but are there a certain set or number of labels turned green that you look for before digging further to determine if a trade is applicable?
* may have answerd my own questions, if I delete last line will I see the score? "score.hide();"
The Indicator is set to automatically display the most recent data available from the ToS Data Feeds.Hello everyone,
MerryDay this is a great indicator and love to look at the fundamentals of the companies as well. I was wondering if the indicator automatically updates data and score after earings or is there something I need to do? Thanks for posting this very cool tool.
Hi there, new to this forum and coding. I removed the last line "score.hide();" and I'm viewing a daily chart, but I still am not seeing a score. Any suggestions? @danjohThanks for the heads up... I didn't realize when I posted the latest version, that I mistakenly hid 'score'
Yes, score gives you an overall financial health. I look for 7-8 or better.
Some would argue that it is more important than ever to trade financially strong stocks, so I put the code for the score back in; you can copy&paste the new code in the top post.Hi there, new to this forum and coding. I removed the last line "score.hide();" and I'm viewing a daily chart, but I still am not seeing a score. Any suggestions? @danjoh
Even without the score, this script is extremely useful so thank you.
Thank you very much!Some would argue that it is more important than ever to trade financially strong stocks, so I put the code for the score back in; you can copy&paste the new code in the top post.
I removed it at the end of the year when it became apparent that we would enter a bear market in 2022.
In the inflationary part of the cycle: inventory turns, interest rates, financial leverage, debt to capital almost always take a hit.
Sales and gross margins take a hit in the recessionary part of the downturn.
So there is currently no recommended overall score.
https://usethinkscript.com/threads/...labels-for-thinkorswim.5308/page-4#post-88803Great indicator, has anyone been able modify this to be able to scan for names with a >= score?
Hi MerryDay,This indicator displays fundamental data of a stock, including financial info such as Free Cash Flow, Profit Margin, etc., on your chart.
An overall weighted Score is calculated to gauge the overall financial health.
Use on a Daily Chart. Useful for anyone interested in fundamental stock research.
Ruby:#Fundamental Data Labels _Mobius 4/26/20 (found on OneNote) # # @MerryDay revised 4/21: # my interpretation of positive/negative values; should be modified to meet your strategy # then calculated an overall weighted score based on: # https://tradestation.tradingappstore.com/products/FundamentalScore/document/Fundamental_Score.pdf # and other information found on the web declare lower; DefineGlobalColor("Pre_Cyan", CreateColor(50, 200, 255)) ; DefineGlobalColor("LabelGreen", CreateColor(0, 165, 0)) ; DefineGlobalColor("LabelRed", CreateColor(225, 0, 0)) ; DefineGlobalColor("Violet", CreateColor (200, 125, 255)) ; DefineGlobalColor("GrayGreen", CreateColor(155, 167, 76)) ; DefineGlobalColor("LitePink", CreateColor (220, 180, 180)) ; DefineGlobalColor("neutral", color.light_gray) ; def fp = FiscalPeriod.YEAR; def EPS = EarningsPerShareTTM(fiscalPeriod = fp); def PE = round(close / EPS,1); AddLabel(PE, "P/E ratio = " + Round(PE, 2), if PE < 0 then GlobalColor("LitePink") else if PE < 20 then GlobalColor("LabelGreen") else if PE < 40 then GlobalColor("GrayGreen") else GlobalColor("Pre_Cyan")); def EarnPerShare = if IsNaN(EarningsPerShareTTM()) then EarnPerShare[1] else EarningsPerShareTTM(); AddLabel(EarnPerShare, "EPS-TTM = " + AsDollars(EarnPerShare), if EarnPerShare > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def FreeCashFlowPerSh = if isNaN(FreeCashFlowPerShare()) then FreeCashFlowPerSh[1] else FreeCashFlowPerShare(); AddLabel(FreeCashFlowPerSh, "Free Cash Flow Per Share = " + AsDollars(FreeCashFlowPerSh), if FreeCashFlowPerSh > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_EarnCash = if PE <0 and FreeCashFlowPerSh < 0 and EarnPerShare < 0 then 0 else 5; def Gross_Profit_Margin = if IsNaN(GrossProfitMargin()) then Gross_Profit_Margin[1] else GrossProfitMargin(); AddLabel(Gross_Profit_Margin, "Gross Profit Margin = " + Round(Gross_Profit_Margin, 2), if Gross_Profit_Margin > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def Operating_Profit_Margin = if IsNaN(OperatingProfitMargin()) then Operating_Profit_Margin[1] else OperatingProfitMargin(); AddLabel(Operating_Profit_Margin, "Operating Profit Margin = " + Round(Operating_Profit_Margin, 2), if Operating_Profit_Margin > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def Net_Profit_Margin = if IsNaN(NetProfitMargin()) then Net_Profit_Margin[1] else NetProfitMargin(); AddLabel(Net_Profit_Margin, "Net Profit Margin = " + Round(Net_Profit_Margin, 2), if Net_Profit_Margin > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_Profits = if Gross_Profit_Margin>0 or Net_Profit_Margin>0 or Operating_Profit_Margin > 0 then 3 else 0 ; def CurRatio = if IsNaN(CurrentRatio()) then CurRatio[1] else CurrentRatio(); AddLabel(CurRatio, "Current Ratio = " + Round(CurRatio, 2), if CurRatio > 2 then GlobalColor("GrayGreen") else if CurRatio >= 1 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def Quick_Ratio = if IsNaN(QuickRatio()) then Quick_Ratio[1] else QuickRatio(); AddLabel(Quick_Ratio, "Quick Ratio = " + Round(Quick_Ratio, 2), if Quick_Ratio > 2 then GlobalColor("GrayGreen") else if Quick_Ratio >= 1 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_Ratios = if Quick_Ratio >= 1 or CurRatio >= 1 then 3 else 0; def Return_On_Assets = if IsNaN(ReturnOnAssets()) then Return_On_Assets[1] else ReturnOnAssets(); AddLabel(Return_On_Assets, "Return On Assets = " + Round(Return_On_Assets), if Return_On_Assets >= 15 then GlobalColor("Pre_Cyan") else if Return_On_Assets >= 10 then GlobalColor("LabelGreen") else if Return_On_Assets > 0 then GlobalColor("GrayGreen") else GlobalColor("LitePink")); def Return_On_Equity = if IsNaN(ReturnOnEquity()) then Return_On_Equity[1] else ReturnOnEquity(); AddLabel(Return_On_Equity, "Return On Equity = " + Round(Return_On_Equity), if Return_On_Equity >= 15 then GlobalColor("Pre_Cyan") else if Return_On_Equity >= 10 then GlobalColor("LabelGreen") else if Return_On_Equity > 0 then GlobalColor("GrayGreen") else GlobalColor("LitePink")); def score_Returns = if Return_On_Equity >= 10 or Return_On_Assets >=10 then 1 else 0 ; def Sales_Per_Share = if IsNaN(SalesPerShare()) then Sales_Per_Share[1] else SalesPerShare(); AddLabel(Sales_Per_Share, "Sales Per Share = " + Round(Sales_Per_Share, 2), if Sales_Per_Share > 0 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_Sales_Per_Share = if Sales_Per_Share > 0 then 1 else 0; def FixChgCovRatio = if IsNaN(FixedChargeCoverageRatio()) then FixChgCovRatio[1] else FixedChargeCoverageRatio(); AddLabel(FixChgCovRatio, "Fixed Charge Coverage Ratio = " + Round(FixChgCovRatio, 2), if FixChgCovRatio >= 1 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def Total_Asset_Turnover = if IsNaN(TotalAssetTurnover()) then Total_Asset_Turnover[1] else TotalAssetTurnover(); AddLabel(Total_Asset_Turnover, "Total Asset Turnover = " + Round(Total_Asset_Turnover, 2), if Total_Asset_Turnover > 1 then GlobalColor("LabelGreen") else GlobalColor("neutral")); def FinLev = if IsNaN(FinancialLeverage()) then FinLev[1] else FinancialLeverage(); AddLabel(FinLev, "Financial Leverage = " + Round(FinLev, 2), if FinLev > 0 and FinLev < 2 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_FinLev = if FinLev < 2 then 1 else 0; def BookValue = if IsNaN(BookValuePerShare()) then BookValue[1] else BookValuePerShare(); AddLabel(BookValue, "Book Value Per Share = " + Round(BookValue), if BookValue < 2 then GlobalColor("Pre_Cyan") else if BookValue < 3 then GlobalColor("LabelGreen") else GlobalColor("neutral")); def Long_Term_Debt_To_Capital = if IsNaN(LongTermDebtToCapital()) then Long_Term_Debt_To_Capital[1] else LongTermDebtToCapital(); AddLabel(Long_Term_Debt_To_Capital, "Long Term Debt To Capital = " + Round(Long_Term_Debt_To_Capital, 2), if Long_Term_Debt_To_Capital < 5 then GlobalColor("LabelGreen") else GlobalColor("LitePink")); def score_Long_Term_Debt_To_Capital = if Long_Term_Debt_To_Capital < 5 then 1 else 0; def Inventory_Turnover = if IsNaN(InventoryTurnover()) then Inventory_Turnover[1] else InventoryTurnover(); AddLabel(Inventory_Turnover, "Inventory Turnover = " + Round(Inventory_Turnover, 2), if Inventory_Turnover < 5 then GlobalColor("LitePink") else if Inventory_Turnover < 10 then GlobalColor("Pre_Cyan") else if Inventory_Turnover < 15 then GlobalColor("GrayGreen") else GlobalColor("LitePink")); def DivPayout = if IsNaN(DividendPayout()) then DivPayout[1] else DividendPayout(); AddLabel(DivPayout, "Dividend Payout = " + round(DivPayout,2) + "%", GlobalColor("neutral")); def DivPerShare = if IsNaN(DividendsPerShareTTM()) then DivPerShare[1] else DividendsPerShareTTM(); AddLabel(DivPerShare, "Dividend Per Share = " + AsDollars(DivPerShare), GlobalColor("neutral")); def DivYield = if IsNaN(DividendsPerShareTTM()) then DivPerShare[1] else DividendsPerShareTTM()/Close; AddLabel(DivPerShare, "Dividend Yield = " + AsPercent(DivYield), GlobalColor("neutral")); def Interest_Rate = if IsNaN(InterestRate()) then Interest_Rate[1] else InterestRate(); AddLabel(Interest_Rate, "Interest Rate = " + Round(Interest_Rate, 2), GlobalColor("neutral")); def Tax_Rate = if IsNaN(TaxRate()) then Tax_Rate[1] else TaxRate(); AddLabel(Tax_Rate, "Tax Rate = " + Round(Tax_Rate, 2), GlobalColor("neutral")); plot score = score_Returns + score_EarnCash + score_ratios + score_Profits + score_FinLev + score_Sales_Per_Share + score_Long_Term_Debt_To_Capital; AddLabel(yes, "SCORE: " + score, if score >= 12 then GlobalColor("Pre_Cyan") else if score >= 10 then GlobalColor("LabelGreen") else if score >= 8 then GlobalColor("GrayGreen") else GlobalColor("LitePink"));
@bboyapollo ...I'm not MerryDay and didn't write the code here but will attempt to help answer your questions.Hi MerryDay,
I see you posted this code a while ago and I am just finding it. Apologies.
I want help understanding this code. Dont understand this line:
def EarnPerShare = if IsNaN(EarningsPerShareTTM())
then EarnPerShare[1]
else EarningsPerShareTTM();
I guess I dont understand the use of "if IsNaN " function. as well as "then EarnPerShare[1]" whats with the [1] ???
Is the code saying... if the current EarningsPerShareTTM() is NOT a number then use EarnPerShare[1] ???? what does that even mean??
How can use EarnPerShare[1] within its own definition ?
I apologize I'm super new to coding thinkscript and I wanted to see if I can go line-by-line and understand whats happening. probably should start with another piece of code, maybe. (if so, any recommendations?)
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.