EPS growth not show correctly

talktohe

New member
I would like to write a code for a scanner that scans stocks with minimum 25% increase in EPS annually. However, no results when the interval was selected as Month. What's wrong with the code?

Code:
Def percentage = 0.25;
def AE = if IsNaN(GetActualEarnings()) then 0 else GetActualEarnings();
Def EPS_TTM = sum(AE, 12);
Def EPS2Years = sum (AE,24) - sum (AE,12);
Def EPS3Years = sum (AE,36) - sum (AE,24);
Def PrcntChng2 = (EPS_TTM/EPS2Years)-1;
Def PrcntChng3 = (EPS2Years/EPS3Years)-1;

Plot Signal= prcntChng2 >= percentage and
                      prcntChng3 >= percentage;
 

rad14733

Well-known member
VIP
@talktohe Here is a hint for determining if your scan logic is correct... If you place the code above in a Study and add a couple AddLabel() calls you can see whether your logic for your def calculations are resulting in the correct numbers... If I was going to debug the code for you that's what I'd probably do so give it a try...
 

talktohe

New member
@rad14733 I tried to add one addlabel with the code on top of unusual volume study (default from TOS), but the code is problematic.

Def percentage = 0.25;
def AE = if IsNaN(GetActualEarnings()) then 0 else GetActualEarnings();
Def EPS_TTM = sum(AE, 12);
Def EPS2Years = sum (AE,24) - sum (AE,12);
Def EPS3Years = sum (AE,36) - sum (AE,24);
Def PrcntChng2 = (EPS_TTM/EPS2Years)-1;
Def PrcntChng3 = (EPS2Years/EPS3Years)-1;

Plot Signal= prcntChng2 >= percentage and
prcntChng3 >= percentage;

AddLabelel (yes, PrcntChng2);

input price = volume;
input choice = {default increased, decreased};
input percent = 20;
input length = 50;
def avg = average(price, length)[1];
def chg = 100*(price/avg -1);
plot scan;

switch (choice) {
case increased:
scan = chg >= percent;
case decreased:
scan = chg <= -percent;
}
 

rad14733

Well-known member
VIP
@talktohe Define "problematic"... The code below is what I was referring to for debugging... I'm attempting to teach you to help yourself, not to solve your problems for you... It's your vision, bring it to reality... Obviously, your logic must be flawed because you aren't getting any real results...

Edited to add: Upon further review, even the Learning Center code for GetActualEarnings() doesn't work so it either only works during regular trading hours or the function is broken... I tried multiple symbols to no avail... You may need to call TOS support...

Ruby:
Def percentage = 0.25;
def AE = if IsNaN(GetActualEarnings()) then 0 else GetActualEarnings();
Def EPS_TTM = sum(AE, 12);
Def EPS2Years = sum (AE,24) - sum (AE,12);
Def EPS3Years = sum (AE,36) - sum (AE,24);
Def PrcntChng2 = (EPS_TTM/EPS2Years)-1;
Def PrcntChng3 = (EPS2Years/EPS3Years)-1;

Plot Signal= prcntChng2 >= percentage and
prcntChng3 >= percentage;

AddLabel(yes, "AE: " + AE, Color.WHITE);
AddLabel(yes, "EPS_TTM: " + EPS_TTM, Color.WHITE);
AddLabel(yes, "EPS2Years: " + EPS2Years, Color.WHITE);
AddLabel(yes, "EPS3Years: " + EPS3Years, Color.WHITE);
AddLabel(yes, "PrcntChng2: " + PrcntChng2, Color.WHITE);
AddLabel(yes, "PrcntChng3: " + PrcntChng3, Color.WHITE);
 
Last edited:

Similar threads

Top