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.
Once a 9 count has been reached the trend(up or down) is exhausted and indicates when to open a long or short position fairly accurately. (i find it most accurate on 1hr candles but you can backtest other candle durations to find more/other accurate candle stick times....