Bollinger Breakout Strategy

Pine Script strategy by Chart GT · Published

Goes long on a close above the upper band and exits on a close below the basis.

Tags: strategy, breakout, volatility

Source code

//@version=6
// @name Bollinger Breakout Strategy
// @description Goes long on a close above the upper band and exits on a close below the basis.
// @tags strategy,breakout,volatility
strategy("Bollinger Breakout Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
length = input.int(20, "Length", minval=1)
mult = input.float(2.0, "StdDev multiplier", minval=0.1, step=0.1)
[basis, upper, lower] = ta.bb(close, length, mult)
plot(basis, "Basis", color=color.orange)
plot(upper, "Upper", color=color.blue)
plot(lower, "Lower", color=color.blue)
if close > upper and strategy.position_size == 0
    strategy.entry("Breakout", strategy.long)
if close < basis
    strategy.close("Breakout")

License: MPL-2.0

Open the chart to add it, or browse more community scripts.