
This strategy uses Bollinger Bands as buy and sell signals. It buys when the price breaks below the lower band and sells when it breaks above the upper band. It also employs a pyramiding approach, continuing to buy when the number of open positions is below a set value and selling when above it. The strategy is suitable for market conditions with clear trends.
The Bollinger Bands Breakout strategy uses the position of the price relative to the Bollinger Bands to generate trend-following signals, while amplifying trend profits through pyramiding. However, it performs poorly in rangebound markets, and pyramiding may amplify losses. Therefore, in actual use, it needs to be combined with other indicators to verify signals, control pyramiding risks, and optimize parameters. At the same time, the strategy should be flexibly adjusted according to market characteristics.
/*backtest
start: 2023-04-19 00:00:00
end: 2024-04-24 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Bollinger Bands Breakout Strategy", overlay=true, initial_capital=100, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Définition des paramètres
length = input(20, title="Bollinger Bands Length")
multiplier = input(2.0, title="Multiplier")
pyramiding = input(10, title="Pyramiding")
// Calcul des bandes de Bollinger
basis = ta.sma(close, length)
dev = multiplier * ta.stdev(close, length)
upper_band = basis + dev
lower_band = basis - dev
// Règles d'entrée
buy_signal = close <= lower_band
sell_signal = close >= upper_band
// Gestion des positions
if (buy_signal)
strategy.entry("Buy", strategy.long)
if (sell_signal)
strategy.entry("Sell", strategy.short)
// Pyramiding
if (strategy.opentrades < pyramiding)
strategy.entry("Buy", strategy.long)
else if (strategy.opentrades > pyramiding)
strategy.entry("Sell", strategy.short)
// Tracé des bandes de Bollinger
plot(basis, color=color.blue)
plot(upper_band, color=color.red)
plot(lower_band, color=color.green)