Bollinger Band
Calculate upper, middle, and lower Bollinger Bands based on a moving average and standard deviation. The Bollinger Band rule creates a dynamic volatility envelope around a price series, expanding during volatile periods and contracting during calm periods. This makes it a powerful tool for identifying overbought and oversold conditions, volatility breakouts, and mean-reversion opportunities.
How It Works
The Bollinger Band rule computes three band values from a single source input:
- Middle Band — A moving average of the source over the configured lookback period. This serves as the baseline trend line.
- Upper Band — The middle band plus a specified number of standard deviations. Price touching or exceeding the upper band suggests the market may be overbought or experiencing a volatility expansion.
- Lower Band — The middle band minus a specified number of standard deviations. Price touching or falling below the lower band suggests the market may be oversold or experiencing a volatility expansion.
The standard deviation is calculated over the same lookback period as the moving average, ensuring the bands accurately reflect recent market volatility. A higher standard deviation multiplier creates wider bands that are reached less frequently, while a lower multiplier produces narrower bands that price touches more often.
The middle band can use any of the available moving average algorithms, allowing you to customise the responsiveness and smoothness of the central line. When using the Arnaud Legoux type, the Shift and Sigma parameters control the Gaussian weighting curve.
Inputs
| Input | Description | Required | Default |
|---|---|---|---|
| Source | The numeric data series from which to calculate the Bollinger Bands. Typically connected to a close price, but can be any numeric output. | Yes | — |
| Offset | The number of bars to look back into the historical series before returning the values. An offset of 0 returns the current values, 1 returns the previous bar's values, and so on. | No | 0 |
| Standard Deviations | The number of standard deviations used to calculate the distance between the middle band and the upper and lower bands. The standard setting is 2, which statistically contains approximately 95% of price action. | No | 2 |
| MA Type | The moving average algorithm used to calculate the middle band. Available values: Simple, Exponential, Double Exponential, Running, Weighted, Hull, Arnaud Legoux. | No | Simple |
| MA Length | The number of data points (bars) used for both the moving average and the standard deviation calculation. Shorter lengths make the bands more responsive; longer lengths make them smoother and more stable. | No | 20 |
| Shift | Controls the offset of the Gaussian weighting curve when the MA Type is set to Arnaud Legoux (ALMA). A value of 0 centres the weight on older data, 1 on newer data, and 0.85 is the standard default. | No | 0.85 |
| Sigma | Controls the width of the Gaussian weighting curve when the MA Type is set to Arnaud Legoux (ALMA). Higher values create a broader, smoother curve. | No | 6.0 |
Outputs
| Output | Description | List |
|---|---|---|
| Lower Band Value | The lower Bollinger Band value, calculated as the middle band minus the configured number of standard deviations. Price at or below this level may indicate oversold conditions or a volatility breakout to the downside. | No |
| Middle Band Value | The middle Bollinger Band value, which is the moving average of the source. This serves as the baseline trend line and mean-reversion target. | No |
| Upper Band Value | The upper Bollinger Band value, calculated as the middle band plus the configured number of standard deviations. Price at or above this level may indicate overbought conditions or a volatility breakout to the upside. | No |
Tips
For a mean-reversion strategy, connect the Upper and Lower Band outputs to Compare Switch rules that detect when price crosses outside the bands and then returns inside. A sell signal triggers when price crosses below the upper band from above, and a buy signal triggers when price crosses above the lower band from below. For breakout strategies, look for the bands to narrow significantly (a Bollinger squeeze) and then enter when price breaks decisively through either band. You can combine Bollinger Bands with RSI to confirm overbought or oversold conditions: only take a long trade at the lower band if RSI is also below 30, adding a second layer of confirmation to your entries.
Was this helpful? Let us know