OPEN-SOURCE SCRIPT
Neighboring Price Dispersion [LuxAlgo]

The Neighboring Price Dispersion indicator calculates the standard deviation of historical prices within a specific price-based neighborhood of the current market level, providing a unique perspective on local price density and volatility within a long-term distribution.
🔶 USAGE
The indicator is displayed in a separate pane and represents the volatility of prices immediately surrounding the current market price based on a historical buffer. Unlike standard volatility indicators that measure price change over time, this tool measures the spread of prices across "price space."
Users can use this tool to identify "Price Discovery" zones or areas where the current price is trading in historical voids. When the indicator line disappears and the background is highlighted, it indicates that the current price has few or no "neighbors" within the historical distribution, suggesting the market is exploring new price levels.
🔹 Interpreting Dispersion
🔶 DETAILS
The script maintains a historical buffer of OHLC values (up to 20,000 data points) which are stored in a sorted array. This allows the indicator to construct a "Global Price Distribution" that evolves with every new bar.
Instead of calculating volatility over a lookback period of bars, the script finds the position of the current closing price within the sorted distribution and calculates the standard deviation of the K nearest neighbors.
If the current price is trading in a range it has rarely or never visited within the defined buffer, the indicator will stop plotting. This visual cue signifies that the asset is currently in a state of "discovery," as there is insufficient historical data in that specific price range to determine a local dispersion.
🔶 SETTINGS
🔶 USAGE
The indicator is displayed in a separate pane and represents the volatility of prices immediately surrounding the current market price based on a historical buffer. Unlike standard volatility indicators that measure price change over time, this tool measures the spread of prices across "price space."
Users can use this tool to identify "Price Discovery" zones or areas where the current price is trading in historical voids. When the indicator line disappears and the background is highlighted, it indicates that the current price has few or no "neighbors" within the historical distribution, suggesting the market is exploring new price levels.
🔹 Interpreting Dispersion
- High Dispersion: Indicates that historical price points near the current level are widely spread out. This often suggests a lack of historical agreement on value at that level or a "thin" market area.
- Low Dispersion: Suggests high price density, where many historical data points (OHLC values) are clustered together. These areas often act as "fair value" zones or high-liquidity regions where the market has spent significant time.
- Background Highlights: When the background is colored, it signifies a "Discovery" phase. This occurs when the current price is at an extreme (all-time high/low within the buffer) or in a gap where there aren't enough historical neighbors to calculate a valid dispersion.
- Signal Components: The indicator includes an orange Signal MA to help identify trends in dispersion and a white Cumulative Mean line to represent the long-term average dispersion of the current session.
🔶 DETAILS
The script maintains a historical buffer of OHLC values (up to 20,000 data points) which are stored in a sorted array. This allows the indicator to construct a "Global Price Distribution" that evolves with every new bar.
Instead of calculating volatility over a lookback period of bars, the script finds the position of the current closing price within the sorted distribution and calculates the standard deviation of the K nearest neighbors.
If the current price is trading in a range it has rarely or never visited within the defined buffer, the indicator will stop plotting. This visual cue signifies that the asset is currently in a state of "discovery," as there is insufficient historical data in that specific price range to determine a local dispersion.
🔶 SETTINGS
- Historical Buffer (Bars): The number of historical bars used to build the price distribution. A higher value provides a longer-term memory of price levels.
- Neighboring Range (K): The number of neighboring price points to include in the standard deviation calculation. Smaller values respond more quickly to local gaps, while larger values provide a broader view of density.
- Smoothing: Applies a Simple Moving Average (SMA) to the dispersion calculation to filter out noise and produce smoother visual transitions.
- MA Length: Sets the period for the signal moving average (orange line). This helps smooth the dispersion data to identify broader shifts in price density.
- CMean Multiplier: A multiplier applied to the cumulative mean of the dispersion. This adjusts the level of the white baseline relative to the current dispersion values.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
All content & scripts provided by LuxAlgo are for educational purposes only and are not financial advice.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
All content & scripts provided by LuxAlgo are for educational purposes only and are not financial advice.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.