OPEN-SOURCE SCRIPT

Pivot Highs/Lows with Bar Counts

What does the indicator do?

This indicator adds labels to a chart at swing (a.k.a., "pivot") highs and lows. Each label may contain a date, the closing price at the swing, the number of bars since the last swing in the same direction, and the number of bars from the last swing in the opposite direction. A table is also added to the chart that shows the average, min, and max number of bars between swings.

OK, but how do I use it?

Many markets -- especially sideways-moving ones -- commonly cycle between swing highs and lows at regular time intervals. By measuring the number of bars between highs and lows -- both same-sided swings (i.e., H-H and L-L) and opposite-sided swings (i.e., H-L and L-H) -- you can then project the averages of those bar counts from the last high or low swing to make predictions about where the next swing high or low should occur. Note that this indicator does not make the projection for you. You have to determine which swing you want to project from and then use the bar counts from the indicator to draw a line, place a label, etc.

Example: Chart of BTC/USD

snapshot

The indicator shows pivot highs and lows with bar counts, and it displays a table of stats on those pivots.

If you focus on the center section of the chart, you can see that prices were moving in a sideways channel with very regular highs and lows. This indicator counts the bars between these pivots, and you could have used those counts to predict when the next high or low may have occurred.

The bar counts do not work as well on the more recent section of the chart because there are no regularly time swings.
Cyclesforecastingpivotswing

Open-source script

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 publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Steve Wehba

Disclaimer