3month ROC issue


Currently working on scoring and ranking, the idea is will buy top 3 security (with high 3month rate of change) at the end of the month.

I have already read Multiple Time Frame support in AFL but I still cannot figure out how to get 3month ROC.....

After the article, I wrote below:

monthlyROC = TimeFrameGetPrice( "C", inMonthly, -3 );
monthlyROC_3= ROC( monthlyROC );
AddColumn(monthlyROC_3 ,"3 month Rate of Change ",1.4);

The result of monthlyROC_3 is zero in "Explore".

After that I try (ROC(Close, 90) , the result is different from what I see in Bloomberg.
Am I in the right direction? Thanks for the help.

Your posted code is not proper one.

tmfrm = inMonthly;

TimeFrameSet( tmfrm );
rc_3mth= ROC(C,3);

expandmode = expandLast;
rc_3mth = TimeFrameExpand( rc_3mth, tmfrm, expandmode );

Also see explanations about expanding modes.

Alternatively you may use without TimeFrame functions (if you do not want to get results as per calendar month basis but period of n-days back from current day for each day). Then you should use business days, so not 90 calendar days but rather e.g. 3 times 20.

// if inDaily interval
rc_3mth = ROC(Close, 60);


// if inDaily interval
rc_3mth = ROC(Close, 62);

or whatever you like.

And please use code tags when inserting code. It is mandatory rule according "How to use this site" thread. It is important so that code does get posted correctly (without formatting issues).

1 Like

Thanks for your prompt assistance and will follow the rule sorry

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