Weekly PIVOTS (for hourly chart)
I find that this method is more elegant as it does not mess things up:
IF DAYOFWEEK < DAYOFWEEK[1] THEN
WeeklyPIVOT = -(lowest[121](close) + highest[121](close) + close[1])/3
ELSE
WeeklyPIVOT = Undefined
ENDIF
For MONTHLY PIVOTS I would add 12 ELSEIF where...