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!
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);