Index | Recent Threads | Who's Online | Search

New Thread
This topic has been viewed 154 times and has 6 replies
mm123
Comparing valuations to historical levels

How would I write a buy rule to find when a datapoint is within x% of its historical lows? For example, let's say I wanted to find stocks where the price/tangible book value is within 10% of the previous low?

Thanks.

Mar 15, 2019 3:02:01 PM       
Edit 1 times, last edit by mm123 at Mar 16, 2019 12:46:36 PM
wwasilev
Re: Comparing valuations to historical levels

If life were easy, you could write something like;
Pr2TanBk(0,QTR)/LoopMin("Pr2TanBk(CTR,QTR)",12,0)<1.10


But none of the P123 provided 'Price To *' functions support calls like function(offset,type[,NAHandling]).

You could try and build it up with TanBV(CTR,QTR) and MktCap, but you would need to get historic values for MktCap. There are forum posts that outline how to do that w/ with SharesCur() and Close().

I think with enough hacking, you could find a complete solution.

Walter

Mar 15, 2019 4:03:56 PM       
Edit 1 times, last edit by wwasilev at Mar 15, 2019 4:49:43 PM
mm123
Re: Comparing valuations to historical levels

Thanks Walter. Yes, this could get cumbersome. Maybe some hacking will get me there.

A couple questions ...

1. It looks like this sample formula searches the prior 12 quarters. Am I reading that correctly? If so, is that the limitation? I'd need something more like 10 years+.

2. What about the FHist function? Would that be helpful, and if so what would the buy rule look like?

Thx.

Mar 15, 2019 5:24:29 PM       
wwasilev
Re: Comparing valuations to historical levels

1. It looks like this sample formula searches the prior 12 quarters. Am I reading that correctly? If so, is that the limitation? I'd need something more like 10 years+.

Yes, you're reading is correctly. There are P123 built in limitations to lookback. It think it may be 20 quarters, but I'm not really sure.
2. What about the FHist function? Would that be helpful, and if so what would the buy rule look like?

I think you'll run into the classic function w/ quoted args embedded in a function w/ quoted args problem.

Actions like what you want should be easier to do. Just sayin'

Walter

Mar 15, 2019 5:54:03 PM       
Edit 3 times, last edit by wwasilev at Mar 15, 2019 6:09:54 PM
mm123
Re: Comparing valuations to historical levels

Ok thanks. Yes, agreed.

Mar 16, 2019 11:40:57 AM       
primus
Re: Comparing valuations to historical levels

Even VB supports nested quotes.

Just saying.

"The world is. The world is. Love and life are deep maybe as his eyes are wide." - Rush, "Tom Sawyer"
http://the-world-is.com/blog

Mar 16, 2019 1:38:47 PM       
yuvaltaylor
Re: Comparing valuations to historical levels

Use two buy rules:
Pr2TanBkQ/Min(FHist("Pr2TanBkQ",10),FHist("Pr2TanBkQ",20),FHist("Pr2TanBkQ",30),FHist("Pr2TanBkQ",40),FHist("Pr2TanBkQ",50),FHist("Pr2TanBkQ",60),FHist("Pr2TanBkQ",70),FHist("Pr2TanBkQ",80),FHist("Pr2TanBkQ",90),FHist("Pr2TanBkQ",100),FHist("Pr2TanBkQ",110),FHist("Pr2TanBkQ",120),FHist("Pr2TanBkQ",130),FHist("Pr2TanBkQ",140),FHist("Pr2TanBkQ",150),FHist("Pr2TanBkQ",160),FHist("Pr2TanBkQ",170),FHist("Pr2TanBkQ",180),FHist("Pr2TanBkQ",190),FHist("Pr2TanBkQ",200)) <= 1.1
and
Pr2TanBkQ/Min(FHist("Pr2TanBkQ",210),FHist("Pr2TanBkQ",220),FHist("Pr2TanBkQ",230),FHist("Pr2TanBkQ",240),FHist("Pr2TanBkQ",250),FHist("Pr2TanBkQ",260),FHist("Pr2TanBkQ",270),FHist("Pr2TanBkQ",280),FHist("Pr2TanBkQ",290),FHist("Pr2TanBkQ",300),FHist("Pr2TanBkQ",310),FHist("Pr2TanBkQ",320),FHist("Pr2TanBkQ",330),FHist("Pr2TanBkQ",340),FHist("Pr2TanBkQ",350),FHist("Pr2TanBkQ",360),FHist("Pr2TanBkQ",370),FHist("Pr2TanBkQ",380),FHist("Pr2TanBkQ",390),FHist("Pr2TanBkQ",400)) <= 1.1
If you apply those to the "All Fundamentals" universe, you get 302 stocks. One of them is Wells Fargo.

Yuval Taylor
Product Manager, Portfolio123
invest(igations)

Mar 18, 2019 9:20:05 AM