TC2000 to AFL conversion

Hi All,

Below is the ADR% formula in Tc2000 provided by Qullamaggie

100*((H0/L0+H1/L1+H2/L2+H3/L3+H4/L4+H5/L5+H6/L6+H7/L7+H8/L8+H9/L9
+H10/L10+H11/L11+H12/L12+H13/L13+H14/L14+H15/L15+H16/L16+H17/L17+H18/L18+H19/L19)/20
-1)

I have tried to convert it to an AFL scanner

ratio = High/Low;
ADR = 100 * (((MA((Sum(ratio, 20) )/ 20, 20))) - 1);
Filter = ADR > 6;
AddColumn(ADR, "ADR", 1.2);

As the values in my scanner and the TC2000 don't match, I believe I am making some mistakes in conversion. Would you mind pointing out the mistakes I'm making?

Thank you in advance for your time and consideration.

Your TC code only calculates SUM, not both sum and then Moving average from sum.
Your AFL code calculates sum then moving average. You made it too complex.
Instead you should just write

ADR = 100 * MA( ratio, 20 ) - 1; // MA already calculates sum and division
1 Like

Thanks, @Tomasz , Worked like a charm.

Parens are off. Correct formula is:

ADR = 100 * (MA(ratio, 20) - 1);

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.