This script shows when price is in a range or trending. When the green line rises above the threshold the price is trending. When the green line falls below the threshold it's ranging. You may try adjusting the lookback way far back to find more areas of resistance.
It shows how many instances the current price has been crossed in the past measured bars. The logic is that any price area that has been crossed many times is a strong area where ranging occurs.
1. Can be used as a dynamic length to other moving averages.
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.