Hello,
I am surprised that no one has been confronted to this problem before. I am wrestling with the question is how to handle properly custom formulas with Loop or LinReg functions?
I currently use Fhist($custom_factor) to handle this but this does not lead to the required result. For example, let’s say I want to compute the moving standard deviation over 12 periods of EPS_TTM.
Since EPS is a built in factor I get this very simple formula:
(LoopStdDev("EPSExclXor(CTR,TTM)",12))
However, if I create a custom formula (let’s say I define $EPSExclXorTTM = EPSExclXorTTM), the best way I found to mimic the behaviour of the formula above is
LoopStdDev("Eval(FHist(PeriodDateQ, CTR) != FHist(PeriodDateQ, CTR+6), FHist($EPSExclXorTTM, CTR), NA)", 26, 0, 6, 0)
The difference of the 2 distributions is in the picture below: Around 500 values (25%) of values are different. This yields in different results during ranking and often increased turnover with my current formula so decreased performance overall (not to mention extended computation times!)
The below picture shows the result of both formulas for a well behaved stock like MSFT
The below picture shows the result of both formulas for a ill behaved stock like GRDX
Please see here the distribution of the difference of the factors over the R3000 universe:
To cover these issues, would it be possible to include custom formulas inside Loop/LinReg functions like this: (LoopStdDev("$EPSExclXorTTM",12)): ie compute rolling standard dev of last 12 values of $EPSExclXor(CTR,TTM).
Thanks to all