Formula to get the "performance of the last month"

Hi P123

I am having trouble to come up with a formula to programmatically calculate the performance of a universe for for the last month.

Well, this one is pretty simple: UnivCapAvg(“1”,“Pr4W%Chg”)
But how would I write that if I would like to have the performance for September?
It would be great if there was a date function to calculate the number of bars and then re-use them somehow.

Anyone having ideas?

Thank you
whotookmynickname

PS: a hack would be to simply look up the number of trading days (https://en.wikipedia.org/wiki/Trading_day#Trading_Days_for_2017 or http://www.swingtradesystems.com/trading-days-calendars.html) and then set the screener to end of month to use:
UnivCapAvg(“1”,“(Close(0)/Close(20)-1)*100”)

This is one of my pet peeves with Portfolio123’s pseudo language, namely its weak date referencing functionality. I brought up something related before in the thread Is this working the way it is supposed to? and also in Year-to-Date Change Formula?

In short, no dice.

A tool to help with your workaround is to use a business days calculator like this one: Business Date Calculator

Marco, pdemartino, aschiff, tedb, hey even you mgerstein, fell free to chime in, why hasn’t date referencing been added as a feature already? From what I know time series data usually includes month day year information. This should be a breeze to implement.

Thanks Marco and team for all the new features and constantly improving P123! The tool is really awesome!

I am just following up:

  1. Does anyone have ideas how to solve this solution?
  2. Could you please introduce a date referencing function please?

Thank you so much!

If #TradingDays were available for the current month, previous month it would be possible to calculate previous month performance
Since it is not available it is possible to derive it
One way I tried to do

  • Create a custom series which just captures the Month for every day (when you reference this series…it is created for trading day)
  • create custom formula to capture the most recent transition point (CTR) when custom series (loop thru the custom series) is current month - 1
  • create custom formula to capture the most recent transition point (CTR) when custom series (loop thru the custom series) is current month - 2

use the two pointers…to derive Prev Month performance

Not very elegant…if someone thinks of a better way, it would be great