Screen by historical factor relative ranking?

Is it possible to search for stocks by how closely a factor or formula compares to prior historical lows/highs? For example, let’s say I want to screen for $EV/EBITDA that is within 5% of that stock’s historical low. If possible, how would I write such a buy rule? Thanks.

One possible solution would be to code something like;

SetVar(@Min,LoopMin("SGA2Sales%(CTR,QTR)",12))
SetVar(@Max,LoopMax("SGA2Sales%(CTR,QTR)",12))
SetVar(@Pct,100*(SGA2Sales%(0,QTR)-@Min)/(@Max-@Min))
@Pct<=5

Obviously, this only works for factors that have the function syntax. If you want to use prebuilt factors, you’ll have to reimplement them with functions. So for example, if you want to use Pr2Book, you’ll need to clobber together the right functions. Unfortunately, commonly used factors, like the Pr2*, are prebuilt and don’t support offsets.

Maybe, to make coding this easier, P123 could add LoopStochastic(). With that available, the above example would look like;

LoopStochastic("SGA2Sales%(CTR,QTR)",12)<=5

Walter

Thanks Walter. Yes, I intend to use Pr2* series, like Pr2TangibleBook, so your suggestion would be very helpful, hope P123 is listening.

Also, are we limited to the last 12 quarters? I’m seeing some valuations comparable to early 2009.

I think it may be up to 20 for QTR. I didn’t check.

One could always combine several LoopMins with Min (and similarly for LoopMax/Max);

SetVar(@Min,Min(LoopMin("SGA2Sales%(CTR,QTR)",20,0),LoopMin("SGA2Sales%(CTR,QTR)",20,20),LoopMin("SGA2Sales%(CTR,QTR)",20,40))