
The strategy is based on the Bollinger Bands indicator. It captures market trends by going short when the price touches the upper band and going long when it touches the lower band. Additionally, the strategy introduces the concept of pyramiding, where it will continue to add positions in the original direction if the number of positions has not reached the set maximum.
Bollinger Bands consists of three lines. The middle band is the simple moving average of the closing price. The upper and lower bands are a certain number of standard deviations above and below the middle band. Since prices always fluctuate around the mean, the upper and lower bands of the Bollinger Bands can be seen as a pressure range for prices. When the price breaks through the upper band, it indicates a strong upward trend and a long position can be taken; a break below the lower band indicates a strong downward trend and a short position can be taken. At the same time, when the number of positions is less than the set maximum, the strategy will continue to add positions on the basis of the original position, amplifying the intensity of trend capture.
The strategy utilizes the trend characteristics of Bollinger Bands. By entering positions when the price touches the upper and lower bands, and amplifying the intensity of trend capture through pyramiding, the overall idea is simple and effective. However, it also has certain lag and parameter sensitivity. In practical applications, attention needs to be paid to optimizing parameters and position management. Consideration can also be given to combining it with other signal indicators in order to obtain more robust strategy performance.
/*backtest
start: 2024-03-01 00:00:00
end: 2024-03-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Bollinger Bands Breakout Strategy", overlay=true)
// Définition des paramètres
length = input(20, title="Bollinger Bands Length")
multiplier = input(2.0, title="Multiplier")
pyramiding = input(5, 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)