Bollinger Bands Strategy — Pine Script & ThinkScript
Bollinger Bands Strategy — 2 Script Files Included
From the AutoTrader Learn series · Includes: Pine Script v5 (TradingView) + ThinkScript (thinkorswim)
Created by John Bollinger in the 1980s, Bollinger Bands consist of a 20-period SMA flanked by upper and lower bands at ±2 standard deviations. They dynamically expand in high-volatility conditions and contract in low-volatility ones — making the Bollinger Squeeze one of the most reliable breakout-detection setups in technical analysis.
Your purchase includes 2 ready-to-use script files:
File 1 — Pine Script v5 for TradingView
- Three signal modes selectable from the inputs panel:
- Mean Reversion — band-touch reversals back toward the midline SMA
- Squeeze Breakout — enters when bands expand after a historically narrow squeeze
- %B Threshold — signals based on the %B oscillator crossing configurable levels
- Configurable SMA length (default 20) and standard deviation multiplier (default 2.0)
- Built-in Squeeze detector using a band-width historical percentile filter
- Stop-loss and take-profit calculated automatically from band width
How to use: Open TradingView → Pine Editor → Paste → Add to chart → select signal mode → Strategy Tester
File 2 — ThinkScript for thinkorswim
- Same three signal modes: Mean Reversion, Squeeze Breakout, and %B Threshold
- Bollinger Squeeze Scanner script included — screen any watchlist for active squeeze setups
- %B indicator plotted as a separate sub-panel
- Configurable band length (default 20) and deviation multiplier (default 2.0)
- Upper/lower band alert conditions ready to activate in the thinkorswim Alert Wizard
How to use: Open thinkorswim → Studies → Edit Studies → Create → Paste → Apply to chart. Use the Scan script to screen your watchlist.
Works on all asset classes. Best results on instruments with well-defined ranges or breakout tendencies.