
이중 트렌드 추적 전략은 슈퍼 트렌드 지표, 이중 지수 이동 평균 (DEMA) 과 브린 밴드를 결합한 복합 전략이다. 그것은 트렌드 반전이 있을 때 구매/판매 신호를 적시에 잡기 위해 여러 기술 지표의 장점을 이용하는 것을 목적으로 한다.
이 전략은 크게 세 부분으로 구성됩니다.
슈퍼 트렌드 지표: 상향 돌파선과 하향 돌파선을 계산하여 현재 트렌드 방향을 판단한다. 가격이 하향으로 슈퍼 트렌드 라인을 돌파할 때 구매 신호를 생성한다. 상향으로 하향으로 돌파할 때 판매 신호를 생성한다.
이중 지수 이동 평균 ((DEMA): 트렌드 추적 지표로, 단순 이동 평균과 지수 이동 평균의 특징을 결합하여 가격 변화에 더 빠르게 반응할 수 있습니다. 전략에 200 일 DEMA를 설정하여 장기 트렌드 방향을 판단합니다.
부린 밴드: 가격 변동의 범위를 나타냅니다. 부린 밴드가 비정상적으로 수축하거나 확장되면, 가능한 추세 반전을 예고합니다.
슈퍼 트렌드 지표와 DEMA가 모두 구매/판매 신호를 발산할 때, 즉 해당 포지션에 진입한다. 또한, 브린 밴드의 이상도 보조 판단의 신호로 사용될 수 있다.
이중 트렌드 추적 전략 다중 지표 조합, 종합적으로 슈퍼 트렌드, DEMA 및 브린 밴드 세 가지의 장점을 활용하여 트렌드를 포착하면서 신호 품질을 향상시키고, 매개 변수를 최적화하여 더 나은 전략 효과를 얻을 수 있습니다. 상쇄 메커니즘의 추가도 미래 최적화 중점입니다.
/*backtest
start: 2023-01-09 00:00:00
end: 2024-01-15 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Supertrend + DEMA + Bollinger Bands", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10, precision=2)
// Input parameters for Supertrend
atrLength = input(title="ATR Period", type=input.integer, defval=12)
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)
showSupertrend = input(title="Show Supertrend Indicator?", type=input.bool, defval=true)
// Input parameters for DEMA
demaLength = input(200, title="DEMA Period")
showDEMA = input(title="Show DEMA Indicator?", type=input.bool, defval=true)
// Calculate ATR for Supertrend
atr2 = sma(tr, atrLength)
atr = changeATR ? atr(atrLength) : atr2
// Calculate Supertrend
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
// Plot Supertrend
upPlot = plot(showSupertrend ? (trend == 1 ? up : na) : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0))
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.new(color.green, 0))
plotshape(buySignal ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0))
dnPlot = plot(showSupertrend ? (trend == 1 ? na : dn) : na, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.new(color.red, 0))
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.new(color.red, 0))
plotshape(sellSignal ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0))
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = (trend == 1 ? color.new(color.green, 80) : color.new(color.white, 0))
shortFillColor = (trend == -1 ? color.new(color.red, 80) : color.new(color.white, 0))
fill(mPlot, upPlot, title="UpTrend Highlighter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highlighter", color=shortFillColor)
// Alert conditions
alertcondition(buySignal, title="Custom Supertrend Buy", message="Custom Supertrend Buy!")
alertcondition(sellSignal, title="Custom Supertrend Sell", message="Custom Supertrend Sell!")
// Calculate DEMA
ema1 = ema(close, demaLength)
dema = 2 * ema1 - ema(ema1, demaLength)
// Plot DEMA with white color
plot(showDEMA ? dema : na, color=color.new(color.white, 0), title="DEMA", linewidth=2)
// Add push notification on mobile if buy and sell occurred
if (buySignal)
strategy.entry("Buy", strategy.long)
strategy.exit("Sell")
alert("Buy Signal - Supertrend")
if (sellSignal)
strategy.entry("Sell", strategy.short)
strategy.exit("Cover")
alert("Sell Signal - Supertrend")