Maximum yield over the previous N years

Hi All,

I’d like to implement a dividend yield model based on the work of Geraldine Weiss. Unfortunately I’m having difficulty implementing the main crux of her thesis: buy when the yield is at least 10% off the long-term maximum yield. How could I screen for such stocks? I assume I need LoopMax(), but not sure the best way to get a yield at a particular point in time.

Thanks
Malcolm

This is clunky and there should be something more elegant, but you could try the following

setvar(@LTMaxYld,LoopMax(“(DivPaid(CTR,TTM)/(Close(CTR*(253/4))*Shares(CTR,TTM)))”,20,0)*100)

Malcom , I was going to suggest using FHist with LoopMax and the Yield factor, but I realized that FHist wants a constant as the offset. So I took a look at the code and there’s no real reason for that restriction. We will release a fix today so that FHist is allowed to have a variable parameter.

Tomorrow do the following (if you do this now you will get an error that FHist wants a constant parameter)

Click on COMPONENTS->Formula and create the following custom formula

$yieldhist

FHist("yield",CTR)

Then use these two rules in the screener. It will show you the maximum yield of Microsoft for the 52 weeks

Ticker("MSFT")
showvar(@maxyield5Y,LoopMax("$yieldhist",52,0,1,1))

When you run the screen and switch to “Screen Factors” you will see that MSFT max yield was 2.0%

Thanks for bringing this up.

NOTES:

dvenin123 suggestion is probably ok but is prone to alignment issues between the dividend stream and financial statements

For your purposes you probably need a longer period and you probably don’t need weekly samples. Something like this

LoopMax("$yieldhist",20,0,13,1)

Gives you the maximum yield for past 5 years (20 * 13 weeks) using 20 samples every 13 weeks.

That FHist change is great! I have other uses in mind, so thank you, Marco!

Walter

Same.

There’s another code tweak in the same vein that I would use.

Loop functions accept only integers in the iterations parameter; they won’t take variables, even when the variables are defined as integers.

For example:

ShowVar(@nQuarters, LoopMax("eval(Sales(CTR,QTR) != NA AND CostG(CTR,QTR) != NA, CTR, NA)", 20, 0, 1) )
showVar(@LoopAvg, LoopAvg("CostG(CTR,QTR)/Sales(CTR,QTR)", @nQuarters, 0, 1) )

returns “[font=courier new]ERROR: Invalid criteria in Rule 2. Invalid parameters for LoopAvg[/font]”.

The example above is rather trivial, yet the ability to define the number of max iterations would be helpful more complicated example (e.g., weighted regression, etc.). Anyone else think it might be useful to pass variables as parameters to the loop functions?

Thanks very much Marco for implementing this change. Swift service indeed!
Looking forward to testing it tomorrow.

Malcolm

It’s live now. MSFT highest yield for the past 10 Y was actually 3.4%. It’s currently around the lowest 10Y yield of around 1.7%. But IBM is currently around the highest 5% yield.

Powerful function it seems.

Enjoy

Note: Some may we wonder why we have to use a custom formula. It’s because our syntax parser does not support nested quotes. Hopefully one day soon will fix this or introduce a way to create custom formulas on the fly.

+1 for both ideas.

The most versatile thing, in my opinion, would be the ability to pass parameters to custom functions, much like we do to native P123 functions.

Nice tweak! Thanks Marco!

just to second David here, the ability to pass parameters to custom functions would be a beautiful thing

-Daniel