0bps

Strategy vault / Breakout

The Bollinger Band breakout strategy is a long only momentum chasing strategy

The Bollinger Band breakout strategy is a long-only momentum chasing strategy. It uses the upper and lower bands of Bollinger Bands to judge price momentum and goes long when price breaks out above the upper band and…

Author
ChaoZhang
Complexity
Starter · 40 lines
Parameters
3
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

The Bollinger Band breakout strategy is a long-only momentum chasing strategy. It uses the upper and lower bands of Bollinger Bands to judge price momentum and goes long when price breaks out above the upper band and closes position when price breaks down the lower band or moving average.

Strategy Logic

The strategy first calculates N-day moving average as the baseline, then adds and subtracts K times standard deviation above and below the baseline to construct upper and lower bands, forming Bollinger Bands. When price breaks out above the upper band, it signals an upward breakout, which is a golden cross signal. The strategy will open long position on this signal. When price breaks down the lower band or moving average, it signals a downward reversal, which is a death cross signal. The strategy will close out positions on this signal.

Since the upper and lower bands of Bollinger Bands can dynamically contain most of the distribution of price data, they represent the reasonable fluctuation range of current market prices. When price breaks through this reasonable fluctuation range, it means something unusual is happening in the market and positions need to be adjusted accordingly. This is the basic logic of the strategy.

Advantage Analysis

The strategy has the following advantages:

  1. Can effectively capture price trends and timely chase market momentum
  2. Uses Bollinger Bands to judge abnormal breakouts, avoiding false breakouts
  3. Clear rules easy to implement and automate
  4. Parameters can be optimized according to market volatility to improve strategy

Risk Analysis

The strategy also has some risks:

  1. Bollinger Bands may fail when extreme volatility occurs
  2. Cannot determine actual market trend, may buy high and sell low
  3. Has some time lag
  4. Ignores trading costs, actual performance will be discounted

To control these risks, we can incorporate trend indicators like MACD, or properly adjust parameters to narrow Bollinger Bands to reduce bad signals.

Optimization Directions

The strategy can also be optimized from the following aspects:

  1. Incorporate trading volume to judge true breakouts
  2. Use adaptive Bollinger Bands to dynamically optimize parameters
  3. Add stop loss mechanisms to control single loss
  4. Increase position management to dynamically adjust positions based on market conditions

Through the above optimizations, we can further improve the stability of the strategy and reduce trading risks.

Conclusion

In summary, the Bollinger Band breakout strategy is a rather classic trend chasing strategy. It has clear logic and easy automation. But there are still some flaws, requiring further optimizations to adapt to complex changing market environments. If combined properly with other indicators and mechanisms, the results can be greatly improved.

Parameters

NameDefaultWhat it controls
v_input_120Period
v_input_21.5Standard Deviation
v_input_3trueExit Option

Source Pine Script

/*backtest
start: 2023-01-22 00:00:00
end: 2024-01-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Senthaamizh

//@version=4
strategy(title="Bollinger Band Breakout", shorttitle = "BB-BO", overlay=true)
source = close
length = input(20, minval=1, title = "Period") //Length of the Bollinger Band 
mult = input(1.5, minval=0.001, maxval=50, title = "Standard Deviation") // Use 1.5 SD for 20 period MA; Use 2 SD for 10 period MA 
exit = input(1, minval=1, maxval=2,title = "Exit Option") // Use Option 1 to exit using lower band; Use Option 2 to exit using moving average

basis = sma(source, length)
dev = mult * stdev(source, length)

upper = basis + dev
lower = basis - dev

if (crossover(source, upper))
    strategy.entry("Long", strategy.long, qty=1)

if(exit==1)
    if (crossunder(source, lower))
        strategy.close("Long")

if(exit==2) //basis is good for N50 but lower is good for BN (High volatility)
    if (crossunder(source, basis))
        strategy.close("Long")

plot(basis, color=color.red,title= "SMA")
p1 = plot(upper, color=color.blue,title= "UB")
p2 = plot(lower, color=color.blue,title= "LB")
fill(p1, p2)

Published by ChaoZhang on the FMZ strategy square · last modified 2024-01-29. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/The-Bollinger-Band-breakout-strategy-is-a-long-only-momentum-chasing-strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open