The Complete Guide to Bollinger Bands for Developers
Everything developers need to know about Bollinger Bands: the math, the API, and three proven trading strategies you can implement today.
What Bollinger Bands Tell You
Bollinger Bands are a volatility envelope around a moving average. The bands widen when volatility increases and contract when it decreases. For a developer building trading systems, they provide three actionable data points: dynamic support (lower band), dynamic resistance (upper band), and a volatility measure (bandwidth).
The Math (So You Know What the API Computes)
- Middle Band = 20-period Simple Moving Average (SMA)
- Upper Band = Middle Band + (2 x 20-period Standard Deviation)
- Lower Band = Middle Band - (2 x 20-period Standard Deviation)
- Bandwidth = (Upper - Lower) / Middle
- %B = (Price - Lower) / (Upper - Lower)
You do not need to compute any of this yourself. The TickAtlas API returns all five values pre-calculated.
API Response
// GET /v1/indicators?symbol=EURUSD&timeframe=H1&indicators=BBANDS_20
{
"success": true,
"data": {
"symbol": "EURUSD",
"timeframe": "H1",
"indicators": {
"BBANDS_20": {
"upper": 1.0892,
"middle": 1.0856,
"lower": 1.0820,
"bandwidth": 0.0066
}
},
"price": {
"close": 1.0835
},
"timestamp": "2026-03-28T14:00:00Z"
}
} Strategy 1: Bollinger Bounce (Mean Reversion)
Price tends to revert to the middle band. When price touches the lower band, it often bounces back. Combine with RSI for confirmation.
import requests
API_KEY = "your_api_key_here"
BASE_URL = "https://tickatlas.com/v1"
def bollinger_bounce(symbol: str) -> str:
resp = requests.get(f"{BASE_URL}/indicators", params={
"symbol": symbol,
"timeframe": "H1",
"indicators": "BBANDS_20,RSI_14"
}, headers={"X-API-Key": API_KEY})
data = resp.json()["data"]
price = data["price"]["close"]
bb = data["indicators"]["BBANDS_20"]
rsi = data["indicators"]["RSI_14"]["value"]
# Buy: price at/below lower band + RSI confirms oversold
if price <= bb["lower"] * 1.002 and rsi < 35:
return f"BUY {symbol} — bouncing off lower BB ({bb['lower']:.5f}), RSI {rsi:.1f}"
# Sell: price at/above upper band + RSI confirms overbought
if price >= bb["upper"] * 0.998 and rsi > 65:
return f"SELL {symbol} — rejected at upper BB ({bb['upper']:.5f}), RSI {rsi:.1f}"
return "HOLD" Strategy 2: Bollinger Squeeze (Breakout)
When bandwidth contracts to historically low levels, a big move is coming. The squeeze does not tell you the direction — but a breakout above the upper band is bullish, and below the lower band is bearish.
def bollinger_squeeze(symbol: str) -> str:
resp = requests.get(f"{BASE_URL}/indicators", params={
"symbol": symbol,
"timeframe": "H4",
"indicators": "BBANDS_20,ADX_14"
}, headers={"X-API-Key": API_KEY})
data = resp.json()["data"]
price = data["price"]["close"]
bb = data["indicators"]["BBANDS_20"]
adx = data["indicators"]["ADX_14"]["value"]
# Detect squeeze: low bandwidth + low ADX
if bb["bandwidth"] < 0.003 and adx < 20:
return f"SQUEEZE {symbol} — bandwidth {bb['bandwidth']:.4f}, ADX {adx:.1f}. Breakout imminent."
# Breakout confirmation
if bb["bandwidth"] > 0.005 and price > bb["upper"]:
return f"BREAKOUT UP {symbol} — price above upper BB after squeeze"
if bb["bandwidth"] > 0.005 and price < bb["lower"]:
return f"BREAKOUT DOWN {symbol} — price below lower BB after squeeze"
return "HOLD" Strategy 3: Bollinger Band Walk (Trend Following)
In strong trends, price "walks" along the upper or lower band for extended periods. Instead of fading the band touch, you ride it.
def bollinger_walk(symbol: str) -> str:
resp = requests.get(f"{BASE_URL}/indicators", params={
"symbol": symbol,
"timeframe": "H1",
"indicators": "BBANDS_20,ADX_14,MACD"
}, headers={"X-API-Key": API_KEY})
data = resp.json()["data"]
price = data["price"]["close"]
bb = data["indicators"]["BBANDS_20"]
adx = data["indicators"]["ADX_14"]["value"]
macd_hist = data["indicators"]["MACD"]["histogram"]
# Strong uptrend: price near upper band + ADX strong + MACD bullish
if adx > 25 and price > bb["middle"] and macd_hist > 0:
if price > bb["upper"] * 0.998:
return f"TREND BUY {symbol} — walking upper band, ADX {adx:.1f}"
# Strong downtrend: price near lower band + ADX strong + MACD bearish
if adx > 25 and price < bb["middle"] and macd_hist < 0:
if price < bb["lower"] * 1.002:
return f"TREND SELL {symbol} — walking lower band, ADX {adx:.1f}"
return "HOLD" Key Developer Considerations
Bandwidth is Your Volatility Metric
Track bandwidth over time. A declining bandwidth for 20+ candles signals an impending volatility expansion. Use this to prepare your strategy.
Always Combine with a Trend Filter
Use ADX to determine which Bollinger strategy to apply: mean reversion when ADX < 20, trend following when ADX > 25.
Multi-Timeframe Confirmation
A Bollinger squeeze on H4 is more significant than on M15. Check multiple timeframes before acting on a squeeze signal.
Further Reading
Try this with live data
Every account gets $2.50 in free PAYG credits. No card required — paste your API key and run the code above against live broker data.
Keep reading
All articles- Guide 14 min read
Algorithmic Trading for Beginners: From Zero to First Bot
A beginner-friendly guide to algorithmic trading. Learn the core concepts, pick your first strategy, and build a working bot with Python and the TickAtlas API.
March 28, 2026
- Guide 13 min read
Building Autonomous Trading Agents with LLMs
A practical guide to building AI agents that autonomously monitor markets, analyze opportunities, and generate trading signals using LLMs and the TickAtlas API.
March 28, 2026
- Guide 10 min read
Bitcoin Technical Analysis API: RSI, MACD, and More for BTC
A developer's guide to analyzing Bitcoin with technical indicators via the TickAtlas API. Covers BTC-specific strategies, volatility management, and real code examples.
March 28, 2026