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
- Basic understanding of entry conditions
- Familiarity with volatility indicators
Understanding Bollinger Bands
What are Bollinger Bands?
Bollinger Bands consist of three lines that measure price volatility and potential overbought/oversold conditions.
Components:
- Middle Band: 20-period Simple Moving Average (SMA)
- Upper Band: Middle Band + (2 × Standard Deviation)
- Lower Band: Middle Band - (2 × Standard Deviation)
Standard Parameters: 20 period, 2 standard deviations
Bollinger Band Signals
| Signal | Interpretation | Action |
|---|---|---|
| Price touches lower band | Oversold | Consider buying (mean reversion) |
| Price touches upper band | Overbought | Consider selling (mean reversion) |
| Price breaks above upper band | Strong momentum | Consider buying (breakout) |
| Price breaks below lower band | Strong momentum | Consider selling (breakout) |
| Bands squeeze (narrow) | Low volatility | Expect breakout soon |
| Bands expand (wide) | High volatility | Trend 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:
- Candle low touches below lower band (tests support)
- 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:
- Candle high touches above upper band (tests resistance)
- 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:
- Close above upper band (breakout)
- RSI above 60 (momentum confirmation)
- 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:
- Price below lower Bollinger Band (oversold by volatility)
- 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:
- Confirms uptrend (price above middle band)
- 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:
- Price is below 2-std lower band (extreme oversold)
- 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:
- Price breaks above upper band
- 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:
- Price to cross back above lower band (reversal confirmed)
- 2 confirmation candles (sustained reversal)
This avoids catching a falling knife.
Verification
After configuring your Bollinger Band conditions:
- Backtest the strategy in both trending and ranging markets
- Check band width - Are bands too tight or too wide?
- Verify signal frequency - Adjust parameters if needed
- Test different standard deviations - Try 1.5, 2, or 2.5
- Paper trade first before going live
Troubleshooting
Problem: Too Many False Signals in Trending Markets
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
-
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
-
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
-
Combine with other indicators:
- BB + RSI: Volatility + momentum confirmation
- BB + MACD: Volatility + trend confirmation
- BB + Volume: Confirm breakout strength
-
Watch for patterns:
- Squeeze: Bands narrow, breakout imminent
- Walking the bands: Strong trend in progress
- M-top/W-bottom: Reversal patterns at bands
-
Use middle band:
- Acts as dynamic support/resistance
- Trend filter (above = bullish, below = bearish)
- Exit signal when price crosses middle band
-
Exit strategies:
- Mean reversion: Exit at opposite band
- Breakout: Exit when price crosses back inside bands
- Trend following: Exit when price crosses middle band