This script is an implementation of Pivot Points in Pine that supports arbitrary session lengths.
It is both a work-in-progress and for amusement, since multiple levels of Trading View support told me parts of this would not be possible to implement in Pine.