Generalized Bollinger Bands %B And Bandwidth
Nov 4, 2022

The Generalized Bollinger Bands %B And Bandwidth indicator provides a versatile implementation of the classic Bollinger Band formula, allowing users to select from various moving averages and deviation calculation methods. This tool goes beyond standard implementations by recalculating the standard deviation based on the chosen basis, ensuring mathematical consistency across different smoothing methods.
Usage
The indicator can be used to assess market sentiment and volatility through its dedicated oscillators and visual cues:
- %B Sentiment: Use the %B value to gauge market direction. Values above 0.5 indicate bullish sentiment, while values below 0.5 suggest bearish sentiment. The "Sentiment Bars" at the bottom provide a visual reference: aqua for bullish, red for bearish, and gray for neutral.
- Bandwidth Analysis: Higher bandwidth values indicate increasing volatility, while lower values suggest consolidation or lower volatility.
- Overbought/Oversold Detection: The background highlights when price moves beyond a selected Bollinger Band threshold (e.g., BB2 or BB3). A common strategy involves looking for exhaustion signals when the background highlight disappears after an extended move.
- Normalized Visualization: Optional plots for normalized Bollinger Bands and OHLC candles allow users to visualize price relative to the bands within a separate pane, regardless of the absolute price value.
Details
Unlike many Bollinger Band variations that only change the basis (moving average) while leaving the standard deviation calculation on a simple moving average, this script updates both. If you choose a Zero-Lag Moving Average (ZLMA) or Median as the basis, the deviation is calculated relative to that specific basis. Advanced implementation details include:
- Temporal Discounting: Allows users to assign more weight to newer bars in deviation calculations, making the bands more responsive to recent price action.
- L-mode Selection: Users can choose between Standard Deviation and Absolute Deviation for the calculation of the bands' width.
- Median Absolute Deviation (MAD): When the basis is set to "median," the script automatically utilizes MAD for more robust statistical analysis.
Settings
- Source: The price source used for calculations (default is Close).
- Lookback period: The length of the smoothing used for the basis and deviation.
- Moving Average Type: Select between SMA, EMA, RMA, WMA, VWMA, SWMA, HMA, ALMA, ZLMA, Approximate SMA, or Median.
- L-mode: Choose between Standard Deviation and Absolute Deviation.
- Bandwidth Multipliers (1-3): Sets the multipliers for three distinct sets of Bollinger Bands.
- Temporal Discount: A value between 0 and 1 to weight recent data more heavily.
- Offset: Shifts the plots forward or backward in time.
- Normalized Plots: Toggle to display rescaled Bollinger Bands or OHLC candles in the indicator pane.
- Highlight %B: Select which band threshold triggers the background overbought/oversold highlighting.
FAQ
How do I access Generalized Bollinger Bands %B And Bandwidth?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
What is the advantage of using ZLMA in this script?
Using ZLMA (Zero-Lag Moving Average) reduces the inherent lag of traditional moving averages. When combined with a tighter lookback period, it can help detect trend shifts more rapidly.
How does Temporal Discounting affect the bands?
Temporal discounting makes the bands more sensitive to recent price volatility by reducing the mathematical impact of older data points within the lookback window.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.