Bollinger Bands 完整教學
不只看「碰上軌賣、碰下軌買」
Bollinger Bands(布林通道)是 John Bollinger 在 1980 年代發明的波動率指標,全球幾乎所有交易者都看過。 但 90% 的人只用「碰上軌賣、碰下軌買」這個入門用法 — 這在強趨勢盤會連續打臉。
本文講原理(為什麼用 ±2 倍標準差)、四種真實用法、 「Squeeze 擠壓」突破策略、Bollinger 自己定義的 Walk the Bands 現象、 完整 Pine 程式碼。
1. Bollinger Bands 的數學原理
三條線:
中軌 = SMA(close, 20) // 20 期簡單移動平均
標準差 = stdev(close, 20) // 過去 20 期收盤價的標準差
上軌 = 中軌 + 2 × 標準差
下軌 = 中軌 - 2 × 標準差關鍵詞:標準差。
為什麼用 ±2 倍標準差?
統計學原理:如果價格分布是常態分布,有 95.4% 的時間落在 ±2σ 內。 意思是「100 根 K 棒中,大約 95 根會在通道內,5 根會碰或穿出去」。
但真實的金融資產不是常態分布 — 會有「肥尾」(fat tails),極端事件比常態多。 所以實際碰軌頻率會比 5% 高。這個偏差是 Bollinger Bands 的陷阱, 也是後面講「Walk the Bands」現象的根源。
2. 入門用法:均值回歸(最常見,最容易死)
直覺:
- 價格碰上軌 → 漲過頭,反彈做空
- 價格碰下軌 → 跌過頭,反彈做多
Bollinger 自己叫這種現象「Walking the Bands」 — 趨勢盤的特徵,不是反轉訊號。
//@version=5
strategy("BB 均值回歸(教學版)", overlay=true)
length = input.int(20, "週期")
mult = input.float(2.0, "標準差倍數")
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upper = basis + dev
lower = basis - dev
// 價格碰下軌 → 買
if (ta.crossunder(low, lower))
strategy.entry("Long", strategy.long)
// 價格碰上軌 → 賣
if (ta.crossover(high, upper))
strategy.entry("Short", strategy.short)
plot(basis, "中軌", color=color.orange)
plot(upper, "上軌", color=color.red)
plot(lower, "下軌", color=color.green)3. 中階用法:Squeeze 突破策略
這是 Bollinger Bands 真正強的用法。 當通道收窄(上下軌靠近),代表波動率變低、 市場在累積能量 → 突破方向常常有大行情。
怎麼定義 Squeeze?
有兩種常見定義:
A. Bollinger Bands Width(BBW)
BBW = (上軌 - 下軌) / 中軌BBW 跌到過去 X 期最低 = Squeeze。Bollinger 自己用 6 個月低點當門檻。
B. Bollinger Squeeze(vs Keltner Channel)
當 Bollinger Bands 完全在 Keltner Channel 內,視為 Squeeze。 這是 John Carter 的版本(《Mastering the Trade》一書)。
//@version=5
strategy("BB Squeeze 突破", overlay=true)
length = input.int(20, "週期")
mult = input.float(2.0, "BB 倍數")
keltnerMult = input.float(1.5, "Keltner 倍數")
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
bbUpper = basis + dev
bbLower = basis - dev
atr = ta.atr(length)
keltnerUpper = basis + keltnerMult * atr
keltnerLower = basis - keltnerMult * atr
// Squeeze 條件:BB 在 Keltner 內
squeeze = bbUpper < keltnerUpper and bbLower > keltnerLower
// Squeeze 結束 + 價格突破上軌 → 做多
if (not squeeze and squeeze[1] and close > bbUpper)
strategy.entry("Long", strategy.long)
// Squeeze 結束 + 價格突破下軌 → 做空
if (not squeeze and squeeze[1] and close < bbLower)
strategy.entry("Short", strategy.short)
plot(basis, "中軌", color=color.orange)
plot(bbUpper, "BB 上軌", color=color.red)
plot(bbLower, "BB 下軌", color=color.green)
bgcolor(squeeze ? color.new(color.purple, 90) : na, title="Squeeze")4. 進階用法:%B 指標
Bollinger 後來自己加了一個輔助指標 %B, 量化價格在通道內的相對位置:
%B = (close - 下軌) / (上軌 - 下軌)
%B = 0 → 價格剛碰下軌
%B = 0.5 → 價格在中軌
%B = 1 → 價格剛碰上軌
%B > 1 → 價格突破上軌(強趨勢)
%B < 0 → 價格突破下軌(強趨勢)用 %B 可以做:
- %B 背離:價格創新高但 %B 沒創新高 → 趨勢動能衰竭
- %B + RSI:當 %B > 0.95 且 RSI > 70 → 雙重超買確認
- %B 突破 0.5:價格從下半部穿到上半部,常作為趨勢開始訊號
5. 高階用法:BB + RSI + 趨勢過濾
Bollinger 自己最推薦的組合用法。完整流程:
- 用 SMA 200 判斷大趨勢方向(在 SMA 200 上方 = 多頭結構)
- 價格回踩 BB 中軌(不是下軌) → 趨勢回踩買點
- RSI 同時 > 50(多頭動能仍在)
- 進場做多
//@version=5
strategy("BB 中軌回踩 + 趨勢過濾", overlay=true)
basis = ta.sma(close, 20)
dev = 2.0 * ta.stdev(close, 20)
upper = basis + dev
lower = basis - dev
sma200 = ta.sma(close, 200)
rsi = ta.rsi(close, 14)
// 多頭結構:價格 > SMA 200 + RSI > 50
bullishStructure = close > sma200 and rsi > 50
// 回踩中軌:低點觸及中軌但收盤站回中軌上
pullback = low <= basis and close > basis
if (bullishStructure and pullback)
strategy.entry("Long", strategy.long)
// 跌破中軌 + RSI < 50 → 出場
if (close < basis and rsi < 50)
strategy.close("Long")
plot(basis, "中軌", color=color.orange)
plot(upper, "上軌", color=color.red)
plot(lower, "下軌", color=color.green)
plot(sma200, "SMA 200", color=color.purple)6. 不同時間框架的 BB 該怎麼解讀
| 時間框架 | BB 用法 | 主要應用 |
|---|---|---|
| 1m / 5m | 雜訊多,不建議 | scalping,但勝率低 |
| 15m / 1h | Squeeze 突破最有效 | 日內波段 |
| 4h | 回踩中軌 + 趨勢過濾 | 2-7 天波段 |
| D / W | 趨勢方向判斷 | 月級別配置 |
7. 常見錯誤
❌ 把 BB 當「絕對範圍」
價格碰上軌 ≠ 一定要賣。在牛市中價格可以「Walking the Bands」連續碰軌十幾根 K。 要看大趨勢結構決定該不該逆勢。
❌ 參數調太短
有人把 length 改成 5、mult 改成 1.0「想更敏感」 — 結果通道太窄、訊號爆量、勝率掉到 30%。 堅持用 20 / 2.0 預設。
❌ 在 Squeeze 期間進場
Squeeze = 沉睡期,市場不動。在這時進場常常被悶到 stop out。 要等 Squeeze 結束 + 有明確突破才進場。
❌ 只看 BB 不看成交量
價格突破上軌但成交量沒放大 → 假突破機率高。 真突破通常伴隨爆量。
Get started
把你的策略接上 TradingView webhook,自動下單到 Binance / OKX / Bybit 等 7 家交易所。
免費註冊 TVSBot8. Bollinger 自己給的「19 條法則」精華
John Bollinger 寫過《Bollinger on Bollinger Bands》一書, 列了 19 條法則。挑最關鍵的:
- 法則 4:價格觸碰通道本身不是訊號, 要配合其他指標確認
- 法則 6:Squeeze 期間市場儲存能量, 突破方向是大行情起點
- 法則 11:Walking the Bands 是趨勢的正常現象, 不要逆勢
- 法則 14:BB 是「相對」工具,不是「絕對」工具 — 上軌只是「相對高」、下軌只是「相對低」