Notes:
1.
Pivot Projection is a very inefficiently-written piece of code. It draws the same lines over and over needlessly (although you can't see this because they're super-imposed).
2. If you program that script in WL5 using the Value method (as above), it will be even more inefficient.
Guys, the Value method for WL5 indicators should
rarely be used. It's the same as the SingleCalcMode in version 4. In Version 5, 99% of the time it's best to use the Series method so that the entire series is calculated once, cached, and then you can reference its values using the indexer - [].
3. If you zig-zag two different series (High and Low in this case), you're likely to find a point in which a new trough doesn't occur between 2 consecutive peaks, and vice-versa. Since the script always looks for the peak before a trough, in effect it masks this phenomenon, although every now and then you're likely to see a trough higher than a peak, for example.
Here's a better start. This version skips right to the peaks and troughs without looping through each bar -
CODE:
Please log in to see this code.