OPEN-SOURCE SCRIPT

Neighboring Price Bands [LuxAlgo]

2 732
The Neighboring Price Bands indicator provides dynamic support and resistance levels based on the local statistical distribution of historical prices relative to the current market position. Unlike traditional volatility bands that rely on fixed standard deviations, this tool identifies "price neighbors" within a sorted historical buffer to determine where the market has previously found friction.

🔶 USAGE

The indicator helps traders identify potential reversal zones and breakout opportunities by analyzing the density of price action around the current level.

🔹 Support and Resistance
The bands act as flexible zones of interest. The upper (green) band represents a bullish boundary derived from historical prices slightly higher than the current price, while the lower (red) band represents a bearish boundary from prices slightly lower. When the price interacts with these bands, it is entering a zone where historical price density suggests a potential reaction.

🔹 Price Discovery & Breakouts
A unique feature of this tool is the "Discovery" mechanism. If the current price moves beyond the range of its historical "neighbors" (e.g., reaching a new multi-period high or low), the corresponding band will disappear, and a background highlight will appear.

  • Bullish Discovery: A green background highlight indicates the price is entering uncharted territory relative to the historical buffer, suggesting a strong bullish breakout.
  • Bearish Discovery: A red background highlight indicates the price is dropping below its local historical distribution, suggesting a strong bearish breakdown.


🔶 DETAILS

The script maintains a historical buffer of prices, which it constantly sorts to create a price distribution. For every new bar, the algorithm performs the following:

  1. It locates the current price within the sorted distribution.
  2. It identifies a specific number of "neighbors" (K) above and below that position.
  3. It calculates a specific percentile within those neighbors to plot the bands.


Because the bands are derived from actual price frequency rather than a calculation like standard deviation (Bollinger Bands) or Average True Range (Keltner Channels), they adapt more specifically to "sticky" price levels where the market has historically spent time.

🔶 SETTINGS

  • Historical Buffer (Bars): The total number of past bars used to build the price distribution. A larger buffer includes more historical context, while a smaller buffer makes the bands more reactive to recent local ranges.
  • Neighboring Range (K): Determines how many samples from the sorted distribution are used to calculate the bands. A smaller K makes the bands tighter and more sensitive to the immediate price position.
  • Percentile: Controls the width of the bands within the neighbor groups. Higher values push the bands further away from the current price.
  • Smoothing: Applies an SMA to the resulting bands to reduce noise and provide a cleaner visual output.

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。