Bollinger Bands Breakout Trend Trading Strategy

Author: ChaoZhang, Date: 2024-02-27 18:00:39



The Bollinger Bands Breakout Trend Trading Strategy is designed to identify potential trend reversals at extreme price levels relative to recent volatility. It combines Bollinger Bands as a mean reversion indicator with breakout logic across the bands to catch the start of new trends.

Strategy Logic

The core strategy logic consists of the following components:

  1. Bollinger Bands plotted as a 20-period EMA +/- 1.5 standard deviations to identify upper and lower bands.

  2. Tracking when the price closes outside the Bollinger Bands 2 periods ago to anticipate potential reversals.

  3. Entry signals triggered when the current bar breaks the high/low of the candle from 2 periods ago that closed beyond the opposite band.

  4. Stop loss set just outside the high/low of the current bar.

  5. Take profit based on predefined risk-reward ratio.


The key advantages of this strategy are:

  1. Bollinger Bands adapt to changing market volatility. Wider bands in volatile markets reduce likelihood of false signals.

  2. Aiming to catch trend reversals early as price breaks back inside the bands.

  3. Flexible risk management with adjustable risk-reward ratio input.

  4. Robust backtesting results in trending markets with sustained directional moves.

  5. Automated trade entry, exit and management once coded into a trading platform.


The main risks to consider:

  1. Potential for whipsaw losses in range-bound non-trending markets.

  2. Stop loss only accounts for current bar’s range, so gaps can cause unwanted liquidations.

  3. Difficult to evaluate performance without extensive backtesting across different market conditions.

  4. Coding errors could lead to unintended order placement or trade management.

Risks can be mitigated through additional filters, evaluating performance in a robust manner and testing vigorously before live deployment.


Some ways in which this strategy could be enhanced:

  1. Adding filters such as volume, RSI or MACD to improve timing and accuracy of signals.

  2. Optimizing Bollinger Bands lengths or standard deviation multiples for specific instruments.

  3. Using different risk-reward ratios per market based on backtest expectation.

  4. Incorporating adaptive stops that trail price once profitable.

  5. Building as an algorithm with automated walking of orders upon entry.

Careful optimization and security selection will be key to successfully implementing this strategy in live markets.


The Bollinger Bands Breakout Trend Trading Strategy offers a rules-based approach to entering into emerging trends across various markets. By combining adaptive bands that account for volatility and early breakout signals, it aims to capture moves as momentum accelerates. However, like all systematic strategies, it will require robust historical analysis and risk management to account for regime changes over market cycles.

start: 2024-02-25 00:00:00
end: 2024-02-26 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]

// This Pine Scriptâ„¢ code is subject to the terms of the Mozilla Public License 2.0 at

strategy("Bollinger Band Strategy with Early Signal (v5)", overlay=true)

// Inputs
length = 20
mult = 1.5
src = close
riskRewardRatio = input(3.0, title="Risk-Reward Ratio")

// Calculating Bollinger Bands
basis = ta.ema(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev

// Plotting Bollinger Bands
plot(upper, "Upper Band",
plot(lower, "Lower Band",

// Tracking Two Candles Ago Crossing Bollinger Bands
var float twoCandlesAgoUpperCrossLow = na
var float twoCandlesAgoLowerCrossHigh = na

if (close[2] > upper[2])
    twoCandlesAgoUpperCrossLow := low[2]
if (close[2] < lower[2])
    twoCandlesAgoLowerCrossHigh := high[2]

// Entry Conditions
longCondition = (not na(twoCandlesAgoLowerCrossHigh)) and (high > twoCandlesAgoLowerCrossHigh)
shortCondition = (not na(twoCandlesAgoUpperCrossLow)) and (low < twoCandlesAgoUpperCrossLow)

// Plotting Entry Points
plotshape(longCondition, title="Buy Signal", location=location.belowbar,, style=shape.labelup, text="BUY")
plotshape(shortCondition, title="Sell Signal", location=location.abovebar,, style=shape.labeldown, text="SELL")

// Strategy Execution
if (longCondition)
    stopLoss = low - (high - low) * 0.05
    takeProfit = close + (close - stopLoss) * riskRewardRatio
    strategy.entry("Buy", strategy.long)
    strategy.exit("Exit Buy", "Buy", stop=stopLoss, limit=takeProfit)

if (shortCondition)
    stopLoss = high + (high - low) * 0.05
    takeProfit = close - (stopLoss - close) * riskRewardRatio
    strategy.entry("Sell", strategy.short)
    strategy.exit("Exit Sell", "Sell", stop=stopLoss, limit=takeProfit)