#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) ;
input lPE = yes ;
input lEPS = yes ;
input lCASH = yes ;
input lGP = yes ;
input lOP = no ;
input lNP = no ;
input lCRatio = no ;
input lQRatio = yes ;
input lROA = no ;
input lROE = yes ;
input lSPS = yes ;
input lFCC = no ;
input lAssTURNS = no ;
input lFinLev = no ;
input lBV = no ;
input lDEBT = yes ;
input lInvTurn = no ;
input lDivOUT = no ;
input lDPS = no ;
input lDIV = no ;
input lIR = no ;
input lTR = no ;
input lSCORE = yes ;
def fp = FiscalPeriod.YEAR;
def EPS = EarningsPerShareTTM(fiscalPeriod = fp);
def PE = round(close / EPS,1);
AddLabel(lPE 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(lEPS 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(lCASH 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(lGP 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(lOP 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(lNP 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(lCRatio 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(lQRatio 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(lROA 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(lROE 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(lSPS 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(lFCC 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(lAssTURNS 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(lFinLev 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(lBV 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(lDEBT 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(lInvTurn 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(lDivOUT and DivPayout, "Dividend Payout = " + round(DivPayout,2) + "%", GlobalColor("neutral"));
def DivPerShare = if IsNaN(DividendsPerShareTTM())
then DivPerShare[1]
else DividendsPerShareTTM();
AddLabel(lDPS and DivPerShare, "Dividend Per Share = " + AsDollars(DivPerShare), GlobalColor("neutral"));
def DivYield = if IsNaN(DividendsPerShareTTM())
then DivPerShare[1]
else DividendsPerShareTTM()/Close;
AddLabel(lDIV and DivPerShare, "Dividend Yield = " + AsPercent(DivYield), GlobalColor("neutral"));
def Interest_Rate = if IsNaN(InterestRate())
then Interest_Rate[1]
else InterestRate();
AddLabel(lIR and Interest_Rate, "Interest Rate = " + Round(Interest_Rate, 2), GlobalColor("neutral"));
def Tax_Rate = if IsNaN(TaxRate())
then Tax_Rate[1]
else TaxRate();
AddLabel(lTR and Tax_Rate, "Tax Rate = " + Round(Tax_Rate, 2), GlobalColor("neutral"));
def score = score_Returns + score_EarnCash + score_ratios + score_Profits
+ score_FinLev + score_Sales_Per_Share + score_Long_Term_Debt_To_Capital;
AddLabel(lSCORE, "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"),
Location.BOTTOM_LEFT);