The Double Bollinger Bands Breakout strategy is a trend following strategy. It uses the upper and lower bands of Bollinger Bands to judge price trends and establish long positions when prices break through the inner Bollinger Bands and close positions when prices fall below the outer Bollinger Bands.
The strategy first calculates the moving average and standard deviation over a specified period. It then constructs the double Bollinger Bands using the moving average ± one standard deviation for the inner bands and the moving average ± 1.5 standard deviations for the outer bands.
When prices break above the upper inner band, it indicates that the market is starting a bull run so goes long. When prices fall below the lower inner band, it indicates the start of a bear market so goes short.
The profit taking exit for long positions is when prices fall below the lower outer band. The profit taking exit for short positions is when prices break above the upper outer band.
The strategy also sets stop loss, take profit and trailing stop loss exits.
The Double Bollinger Bands Breakout strategy has the following advantages:
The Double Bollinger Bands Breakout strategy also has some risks:
To address these risks, parameters could be adjusted, additional filters added, or breakouts manually monitored to reduce risk.
The Double Bollinger Bands Breakout strategy can be optimized in several ways:
The Double Bollinger Bands Breakout strategy overall judges changes in price relative to Bollinger Bands to time entries in a typical trend following approach. The strategy sets profit targets using the double bands and scientific exit mechanisms to control risk. With optimized parameters and risk controls, it can achieve good results.
/*backtest start: 2023-12-17 00:00:00 end: 2023-12-24 00:00:00 period: 15m basePeriod: 5m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=2 strategy("BB Strat",default_qty_type = strategy.percent_of_equity, default_qty_value = 100,currency="USD",initial_capital=100, overlay=true) l=input(title="length",defval=100) pbin=input(type=float,step=.1,defval=.25) pbout=input(type=float,step=.1,defval=1.5) ma=sma(close,l) sin=stdev(ma,l)*pbin sout=stdev(ma,l)*pbout inu=sin+ma inb=-sin+ma outu=sout+ma outb=-sout+ma plot(inu,color=lime) plot(inb,color=lime) plot(outu,color=red) plot(outb,color=yellow) inpTakeProfit = input(defval = 0, title = "Take Profit", minval = 0) inpStopLoss = input(defval = 0, title = "Stop Loss", minval = 0) inpTrailStop = input(defval = 0, title = "Trailing Stop Loss", minval = 0) inpTrailOffset = input(defval = 0, title = "Trailing Stop Loss Offset", minval = 0) useTakeProfit = inpTakeProfit >= 1 ? inpTakeProfit : na useStopLoss = inpStopLoss >= 1 ? inpStopLoss : na useTrailStop = inpTrailStop >= 1 ? inpTrailStop : na useTrailOffset = inpTrailOffset >= 1 ? inpTrailOffset : na longCondition = close>inu and rising(outu,1) exitlong = (open[1]>outu and close<outu) or crossunder(close,ma) shortCondition = close<inb and falling(outb,1) exitshort = (open[1]<outb and close>outb) or crossover(close,ma) strategy.entry(id = "Long", long=true, when = longCondition) strategy.close(id = "Long", when = exitlong) strategy.exit("Exit Long", from_entry = "Long", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset, when=exitlong) strategy.entry(id = "Short", long=false, when = shortCondition) strategy.close(id = "Short", when = exitshort) strategy.exit("Exit Short", from_entry = "Short", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset, when=exitshort)