A rather universal approach to writing indicators of the ZigZag type is proposed. The method includes a significant part of ZigZags already described and allows you to create new ones relatively easily
One day I suddenly realised a simple thing: least-squares approximation is essentially about minimising a linear combination of vectors. That is, some kind of universal approximator function can be manufactured. It's a done deal, so here is the title of the function