A estratégia Supertrend Bollinger Bands é uma estratégia comum de indicador de trailing stop baseada no ATR (Average True Range). Esta estratégia usa o indicador Supertrend para desenhar canais de tendência de alta e baixa no gráfico e gera sinais de negociação em combinação com Bollinger Bands.
A estratégia utiliza dois parâmetros principais - período e multiplicador, com valores predefinidos de 10 e 3 respectivamente.
Linha superior: fechar - (multiplicador x ATR) Linha inferior: Fechar + (multiplicador x ATR)
Quando o preço de fechamento é superior à linha superior anterior, é considerado um sinal de alta.
A estratégia também incorpora o indicador Bollinger Bands, usando a faixa média como linha de base, e as faixas superior e inferior localizadas a dois desvios padrão de distância dela.
A estratégia Supertrend Bollinger Bands integra os pontos fortes de vários indicadores técnicos e utiliza um mecanismo de parada de tração dinâmica para rastrear efetivamente as tendências do mercado. Esta estratégia altamente personalizável se adapta bem a diferentes mercados, tornando-se uma estratégia recomendada de busca de breakout.
/*backtest start: 2022-11-24 00:00:00 end: 2023-11-30 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © KivancOzbilgic //@version=4 strategy("SuperTrend STRATEGY", overlay=true) Periods = input(title="ATR Period", type=input.integer, defval=10) src = input(hl2, title="Source") Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0) changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true) showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=false) highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true) barcoloring = input(title="Bar Coloring On/Off ?", type=input.bool, defval=true) atr2 = sma(tr, Periods) atr= changeATR ? atr(Periods) : atr2 up=src-(Multiplier*atr) up1 = nz(up[1],up) up := close[1] > up1 ? max(up,up1) : up dn=src+(Multiplier*atr) dn1 = nz(dn[1], dn) dn := close[1] < dn1 ? min(dn, dn1) : dn trend = 1 trend := nz(trend[1], trend) trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green) buySignal = trend == 1 and trend[1] == -1 plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0) plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0) dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red) sellSignal = trend == -1 and trend[1] == 1 plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0) plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0) mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0) longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor) fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor) FromMonth = input(defval = 9, title = "From Month", minval = 1, maxval = 12) FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31) FromYear = input(defval = 2018, title = "From Year", minval = 999) ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12) ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31) ToYear = input(defval = 9999, title = "To Year", minval = 999) start = timestamp(FromYear, FromMonth, FromDay, 00, 00) finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) window() => time >= start and time <= finish ? true : false longCondition = buySignal if (longCondition) strategy.entry("BUY", strategy.long) shortCondition = sellSignal if (shortCondition) strategy.entry("SELL", strategy.short) buy1= barssince(buySignal) sell1 = barssince(sellSignal) color1 = buy1[1] < sell1[1] ? color.green : buy1[1] > sell1[1] ? color.red : na barcolor(barcoloring ? color1 : na)