Skip to main content
Skip to main content
Version: 1.0 (Current)

How to Use Bollinger Bands

Problem

You want to use Bollinger Bands to identify volatility, detect overbought/oversold conditions, trade breakouts, or implement mean reversion strategies in your trading algorithm.

Prerequisites

Understanding Bollinger Bands

What are Bollinger Bands?

Bollinger Bands consist of three lines that measure price volatility and potential overbought/oversold conditions.

Components:

  1. Middle Band: 20-period Simple Moving Average (SMA)
  2. Upper Band: Middle Band + (2 × Standard Deviation)
  3. Lower Band: Middle Band - (2 × Standard Deviation)

Standard Parameters: 20 period, 2 standard deviations

Bollinger Band Signals

SignalInterpretationAction
Price touches lower bandOversoldConsider buying (mean reversion)
Price touches upper bandOverboughtConsider selling (mean reversion)
Price breaks above upper bandStrong momentumConsider buying (breakout)
Price breaks below lower bandStrong momentumConsider selling (breakout)
Bands squeeze (narrow)Low volatilityExpect breakout soon
Bands expand (wide)High volatilityTrend in progress

Band Width and Volatility

  • Narrow bands: Low volatility, consolidation
  • Wide bands: High volatility, trending
  • Squeeze: Bands at narrowest point, breakout imminent
  • Expansion: Volatility increasing, trend starting

Solution

Example 1: Mean Reversion - Buy at Lower Band

Enter long when price touches the lower Bollinger Band.

{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"priceType": "low",
"indicator": "BB_Lower",
"period": 20,
"comparison": "below"
},
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Lower",
"period": 20,
"comparison": "above"
}
]
}
}

Explanation: This strategy enters when:

  1. Candle low touches below lower band (tests support)
  2. Candle close is above lower band (bounces back)

This is a classic mean reversion setup.

Example 2: Mean Reversion - Sell at Upper Band

Enter short when price touches the upper Bollinger Band.

{
"entryConditions": {
"positionType": "short",
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"priceType": "high",
"indicator": "BB_Upper",
"period": 20,
"comparison": "above"
},
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Upper",
"period": 20,
"comparison": "below"
}
]
}
}

Explanation: This strategy enters short when:

  1. Candle high touches above upper band (tests resistance)
  2. Candle close is below upper band (rejects)

Perfect for ranging markets.

Example 3: Breakout - Upper Band Break

Enter long when price breaks above the upper band with momentum.

{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Upper",
"period": 20,
"comparison": "above"
},
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "above",
"value": 60
}
],
"confirmationCandles": 1
}
}

Explanation: This breakout strategy requires:

  1. Close above upper band (breakout)
  2. RSI above 60 (momentum confirmation)
  3. 1 confirmation candle (sustained breakout)

Example 4: Bollinger Squeeze Breakout

Enter when bands squeeze and then expand.

{
"entryConditions": {
"positionType": "both",
"logicalOperator": "OR",
"conditions": [
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Upper",
"period": 20,
"comparison": "crosses_above"
},
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Lower",
"period": 20,
"comparison": "crosses_below"
}
]
}
}

Explanation: After a squeeze (narrow bands), enter:

  • Long when price breaks above upper band
  • Short when price breaks below lower band

The direction of the breakout determines the trade direction.

Example 5: Bollinger Band Bounce with RSI

Combine Bollinger Bands with RSI for stronger mean reversion signals.

{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Lower",
"period": 20,
"comparison": "below"
},
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 30
}
]
}
}

Explanation: This strategy requires both:

  1. Price below lower Bollinger Band (oversold by volatility)
  2. RSI below 30 (oversold by momentum)

Double confirmation increases reliability.

Example 6: Middle Band as Dynamic Support/Resistance

Use the middle band (20 SMA) as a trend filter.

{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Middle",
"period": 20,
"comparison": "above"
},
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Lower",
"period": 20,
"comparison": "crosses_above"
}
]
}
}

Explanation: This strategy:

  1. Confirms uptrend (price above middle band)
  2. Enters on pullback to lower band that bounces

This combines trend following with mean reversion.

Example 7: Bollinger Band Walk

Enter when price "walks" along the upper band (strong trend).

{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Upper",
"period": 20,
"comparison": "above"
},
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Middle",
"period": 20,
"comparison": "above"
}
]
},
"exitConditions": {
"customExitConditions": [
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Middle",
"period": 20,
"comparison": "below"
}
]
}
}

Explanation: In strong trends, price can stay near the upper band for extended periods. Enter when price is above upper band, exit when it falls below middle band.

Example 8: Double Bollinger Band Strategy

Use two sets of Bollinger Bands with different standard deviations.

{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Lower",
"period": 20,
"stdDev": 2,
"comparison": "below"
},
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Lower",
"period": 20,
"stdDev": 1,
"comparison": "above"
}
]
}
}

Explanation: This strategy enters when:

  1. Price is below 2-std lower band (extreme oversold)
  2. Price is above 1-std lower band (not too extreme)

This identifies strong but not excessive oversold conditions.

Example 9: Bollinger Band with Volume Confirmation

Add volume confirmation to Bollinger Band signals.

{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Upper",
"period": 20,
"comparison": "crosses_above"
},
{
"type": "indicator_indicator",
"indicator1": "Volume",
"period1": 1,
"indicator2": "SMA",
"period2": 20,
"comparison": "above"
}
]
}
}

Explanation: This breakout strategy requires:

  1. Price breaks above upper band
  2. Volume is above 20-period average

High volume confirms the breakout is genuine.

Example 10: Bollinger Band Reversal at Extremes

Enter when price reverses after touching the bands.

{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"conditions": [
{
"type": "price_indicator",
"priceType": "close",
"indicator": "BB_Lower",
"period": 20,
"comparison": "crosses_above"
}
],
"confirmationCandles": 2
}
}

Explanation: This strategy waits for:

  1. Price to cross back above lower band (reversal confirmed)
  2. 2 confirmation candles (sustained reversal)

This avoids catching a falling knife.

Verification

After configuring your Bollinger Band conditions:

  1. Backtest the strategy in both trending and ranging markets
  2. Check band width - Are bands too tight or too wide?
  3. Verify signal frequency - Adjust parameters if needed
  4. Test different standard deviations - Try 1.5, 2, or 2.5
  5. Paper trade first before going live

Troubleshooting

Solution:

  • Don't use mean reversion in strong trends
  • Use breakout strategy instead
  • Add trend filter (200 EMA)
  • Wait for price to cross back inside bands before entering

Problem: Missing Breakouts

Solution:

  • Use breakout strategy instead of mean reversion
  • Remove confirmation candles
  • Add volume confirmation
  • Watch for band squeeze patterns

Problem: Bands Too Wide or Too Narrow

Solution:

  • Adjust standard deviation (1.5, 2, or 2.5)
  • Change period (15, 20, or 25)
  • Consider using ATR-based bands instead
  • Match parameters to your timeframe

Problem: Whipsaws During Consolidation

Solution:

  • Avoid trading during band squeeze
  • Wait for clear breakout
  • Add confirmation candles
  • Use other indicators (RSI, MACD) for confirmation

Best Practices

  1. Understand market conditions:

    • Ranging markets: Use mean reversion (buy at lower band, sell at upper band)
    • Trending markets: Use breakout strategy (buy above upper band)
    • Consolidation: Wait for squeeze and breakout
  2. Adjust parameters:

    • Standard: 20 period, 2 std dev
    • Tighter bands: 20 period, 1.5 std dev (more signals)
    • Wider bands: 20 period, 2.5 std dev (fewer signals)
    • Faster: 15 period, 2 std dev
    • Slower: 25 period, 2 std dev
  3. Combine with other indicators:

    • BB + RSI: Volatility + momentum confirmation
    • BB + MACD: Volatility + trend confirmation
    • BB + Volume: Confirm breakout strength
  4. Watch for patterns:

    • Squeeze: Bands narrow, breakout imminent
    • Walking the bands: Strong trend in progress
    • M-top/W-bottom: Reversal patterns at bands
  5. Use middle band:

    • Acts as dynamic support/resistance
    • Trend filter (above = bullish, below = bearish)
    • Exit signal when price crosses middle band
  6. Exit strategies:

    • Mean reversion: Exit at opposite band
    • Breakout: Exit when price crosses back inside bands
    • Trend following: Exit when price crosses middle band