Purpose:
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.
Logic:
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.
Ideas:
1. Can be used as a dynamic length to other moving averages.