This strategy is based on Bollinger Bands indicator, taking long or short positions when price breaks out of Bollinger Bands upper or lower lines. It aims to profit from catching breakout moves.
Specifically, it first calculates the midline SMA of length length, and upper/lower lines of mult times standard deviation. When close breaks out upward from the lower line, go long. When close breaks down from the upper line, go short. Also set start and end time to limit trading hours. Exit before daily open.
The strategy attempts to capture expanding moves after price breaks out of bands. Breaking lower band indicates strengthening bullish forces, while breaking upper band means strengthening bearish forces, so trading in line with breakout is favorable.
Risks can be reduced by optimizing entry rules, adding stop loss, introducing trend filter etc.
This is a breakout strategy based on Bollinger Bands. It profits from breakout moves. Pros are simple logic and easy implementation; Cons are susceptibility to false breakouts. Risks can be managed through parameter optimization, stop loss, trading hours control etc. It allows traders to understand basics of using indicators and trading breakouts.
/*backtest start: 2023-08-21 00:00:00 end: 2023-09-20 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //Noro //2018 //@version=2 strategy("Noro's Bollinger Strategy v1.0", shorttitle = "Bollinger str 1.0", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100.0, pyramiding = 5) //Settings needlong = input(true, defval = true, title = "Long") needshort = input(true, defval = true, title = "Short") length = input(20, minval=1) mult = input(1.0, minval=0.001, maxval=50) fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year") toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year") frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month") tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month") source = close basis = sma(source, length) dev = mult * stdev(source, length) upper = basis + dev lower = basis - dev up = close < lower dn = close > upper exit = (strategy.position_size > 0 and close > open) or (strategy.position_size < 0 and close < open) if up strategy.entry("Long", strategy.long, needlong == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, 01, 00, 00) and time < timestamp(toyear, tomonth, 31, 00, 00))) if dn strategy.entry("Short", strategy.short, needshort == false ? 0 : na, when=(time > timestamp(fromyear, frommonth, 01, 00, 00) and time < timestamp(toyear, tomonth, 31, 00, 00))) if time > timestamp(toyear, tomonth, 31, 00, 00) or exit strategy.close_all()