This strategy uses Bollinger Bands as the main indicator, entering a long position when the closing price breaks above the upper band and a short position when it breaks below the lower band. Bollinger Bands consist of a middle band (moving average), an upper band (middle band + standard deviation), and a lower band (middle band - standard deviation). The strategy aims to capture market trends by buying when the price breaks above the upper band and selling when it breaks below the lower band, while using the middle band as the exit condition.
The Bollinger Bands Breakout Strategy captures market trends through breakouts of the upper and lower bands of the Bollinger Bands, with the middle band serving as the exit condition. The strategy logic is clear and easy to implement, and it can effectively capture trends. However, there are certain risks in parameter selection and volatile markets. In the future, the strategy’s performance can be improved by introducing other indicators, optimizing parameters, adding risk management, and other methods.
/*backtest start: 2023-04-24 00:00:00 end: 2024-04-29 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Bollinger Bands Strategy", shorttitle='BB Strategy', overlay=true) // Bollinger Bands parameters length = input.int(20, title="Length") mult = input.float(2.0, title="Multiplier") // Calculate Bollinger Bands basis = ta.sma(close, length) dev = mult * ta.stdev(close, length) upper_band = basis + dev lower_band = basis - dev // Plot Bollinger Bands plot(basis, color=color.blue, title="Basis") plot(upper_band, color=color.red, title="Upper Band") plot(lower_band, color=color.green, title="Lower Band") // Strategy long_condition = ta.crossover(close, upper_band) short_condition = ta.crossunder(close, lower_band) if (long_condition) strategy.entry("Long", strategy.long) if (short_condition) strategy.entry("Short", strategy.short) // Exit conditions exit_long_condition = ta.crossunder(close, basis) exit_short_condition = ta.crossover(close, basis) if (exit_long_condition) strategy.close("Long") if (exit_short_condition) strategy.close("Short")template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6