CANSLIM Label based on EPS and ROE

shakib3585

Active member
VIP
Hello All,

I am attempting to make a CANSLIM label based on EPS_YOY, EPS_QOQ and ROE. My goal is to see the progress from the last three periods as percentages. For example, in the case of EPS_YOY, if this year is 2024, then I would like to see the percent change from 2020 to 2021, 2021 to 2022, and 2022 to 2023. For the quarters, it's the same except they should be compared with respect to previous quarter months. I have attached the code that I have worked on. As I am not that much of an expert, I would sincerely request that you please see if I made any mistakes to achieve my desired results. I know @MerryDay has made an excellent, more elaborate label on CANSLIM and would really appreciate it if you could please step in to check.

Thanks a ton!

Code:
def EarnPerShareY = if isNaN(EarningsPerShareTTM())
                   then EarnPerShareY[1]
                   else EarningsPerShareTTM();
def EPSY1 = if EarnPerShareY != EarnPerShareY[1]
            then EarnPerShareY[1]
            else EPSY1[1];
def EPSY2 = if EarnPerShareY[1] != EarnPerShareY[2]
            then EarnPerShareY[2]
            else EPSY2[1];
def EPSY3 = if EarnPerShareY[2] != EarnPerShareY[3]
            then EarnPerShareY[2]
            else EPSY3[1];
def EPS_YoY1 = ((absvalue(EarnPerShareY) - absvalue(EPSY1))/absvalue(EPSY1));
def EPS_YoY2 = ((absvalue(EPSY1) - absvalue(EPSY2))/absvalue(EPSY2));
def EPS_YoY3 = ((absvalue(EPSY2) - absvalue(EPSY3))/absvalue(EPSY3));

def EarnPerShareQ = if isNaN(EarningsPerShareTTM(fiscalPeriod = FiscalPeriod.QUARTER))
                   then EarnPerShareQ[1]
                   else EarningsPerShareTTM(fiscalPeriod = FiscalPeriod.QUARTER);
def EPSQ1 = if EarnPerShareQ != EarnPerShareQ[1]
            then EarnPerShareQ[1]
            else EPSQ1[1];
def EPS_QOQ1 = ((absValue(EarnPerShareQ) - absvalue(EPSQ1))/absvalue(EPSQ1));
def EPSQ2 = if EarnPerShareQ[1] != EarnPerShareQ[2]
            then EarnPerShareQ[2]
            else EPSQ2[1];
def EPS_QOQ2 = ((absvalue(EPSQ1) - absvalue(EPSQ2))/absvalue(EPSQ2));
def EPSQ3 = if EarnPerShareQ[2] != EarnPerShareQ[3]
            then EarnPerShareQ[3]
            else EPSQ3[1];
def EPS_QOQ3 = ((absvalue(EPSQ2) - absvalue(EPSQ3))/absvalue(EPSQ3));
def Return_On_Equity = if isNaN(ReturnOnEquity())
                       then Return_On_Equity[1]
                       else ReturnOnEquity();
def ROE1 = if Return_On_Equity != Return_On_Equity[1]
           then Return_On_Equity[1]
           else ROE1[1];
def ROE_YOY1 =((absvalue(Return_On_Equity) - absvalue(ROE1))/absvalue(ROE1));
def ROE2 = if Return_On_Equity[1] != Return_On_Equity[2]
           then Return_On_Equity[2]
           else ROE2[1];
def ROE_YOY2 =((absvalue(ROE1) - absvalue(ROE2))/absvalue(ROE2));
def ROE3 = if Return_On_Equity[2] != Return_On_Equity[3]
           then Return_On_Equity[3]
           else ROE3[1];
def ROE_YOY3 =((absvalue(ROE2) - absvalue(ROE3))/absvalue(ROE3));
def NearHigh = (close - Lowest(low, 252))/(Highest(high, 252)-Lowest(low, 252));
def RS = RelativeStrength().RS > RelativeStrength().SRatio;
AddLabel(1, "CANSLIM:  Percent Of Year High = " + AsPercent(NearHigh));
AddLabel(yes,"EPS_YoY1: "+Aspercent(EPS_YoY1), color.white);
AddLabel(yes,"EPS_YoY2: "+Aspercent(EPS_YoY2), color.white);
AddLabel(yes,"EPS_YoY3: "+Aspercent(EPS_YoY3), color.white);
AddLabel(yes,"EPS_QOQ1: "+Aspercent(EPS_QOQ1), color.white);
AddLabel(yes,"EPS_QOQ2: "+Aspercent(EPS_QOQ2), color.white);
AddLabel(yes,"EPS_QOQ3: "+Aspercent(EPS_QOQ3), color.white);
AddLabel(yes,"ROE_1: "+Aspercent(ROE_YOY1), color.white);
AddLabel(yes,"ROE_2: "+Aspercent(ROE_YOY2), color.white);
AddLabel(yes,"ROE_3: "+Aspercent(ROE_YOY3), color.white);
AddLabel(yes,"EPS_Y: "+EarnPerShareY, color.white);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
466 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