I am looking for a custom factor that would calculate the tendency for a stock to mean revert over a look back period of window_length. The output is on a range of 0 (no mean reversion tendency) to 1 (always mean reverts within parameters specified).
To keep it simple one way to define it is looking at two moving averages and if the ratio is above or below certain threshold, would then stock mean revert in the next n days.
I am maybe clumsy explaining it but basically the customer factor would check how mean-reverting the asset is by what ever mean-reverting definition.
Thanks in advance!