I used the highest of the two last highest pivots and the lowest of the two last lowest pivots to calculate "max" and "min" or high level or low level.
I also calculate the average of the 4 values to reach the average line which could be a trend detector in higher lengths.
Default length is 3 but using 10 or 20 as length is really good as trending detector.
I need help to upgrade a trend detector system. please read the script for more information.
Thank you so much.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.