슈퍼트렌드 볼링거 밴드 이중 이동 평균 거래 전략

저자:차오장, 2024-02-23 13:58:36
태그:

img

전반적인 설명

이 전략은 슈퍼트렌드, 듀얼 이동 평균 (DEMA) 및 볼링거 밴드 (Bollinger Bands) 를 포함한 여러 기술적 지표를 통합하여 강점을 활용하고 더 정확한 거래 신호를 생성합니다.

전략 논리

이 전략은 슈퍼트렌드의 상단 및 하단 밴드를 계산하기 위해 12주기 ATR 및 가격 평균을 사용하며, 가격이 그 밴드를 넘을 때 긴 및 짧은 신호를 식별합니다. 한편, 200주기 DEMA는 트렌드 판단에 보조 지표로 사용됩니다. 또한 볼링거 밴드는 입상 및 스톱 손실에 대한 최적의 타이밍을 결정하는 데 도움이됩니다.

구매 신호는 가격이 상위 대역을 넘을 때 생성된다. 판매 신호는 가격이 하위 대역을 넘을 때 생성된다. 가격이 슈퍼트렌드의 상위 또는 하위 대역을 넘을 때, 마커와 텍스트 Buy 또는 Sell가 해당 대역에 그려진다. 모바일 알레르트도 동시에 전송된다.

DEMA는 전체 시장 트렌드 방향을 판단하기 위해 가격 곡선 위에 또는 아래에 흰색으로 표시됩니다.

볼링거 밴드는 입상 및 스톱 손실에 대한 최적의 타이밍을 식별하는 데 사용됩니다. 상부 및 하부 밴드는 가격 변동을 포괄하는 채널을 형성하여 가격이 정상적인 범위에서 벗어났을 때, 즉 과도하게 변동적 인 경우를 결정하는 데 도움이됩니다.

거래에 들어가면 전략은 자동 포지션 감소를 위해 스톱 로스 가격과 스톱 로스 가격을 설정하여 수익을 차단하거나 손실을 줄이기 위해 스톱 로스 및 수익을 취하는 방법을 사용합니다.

이점 분석

여러 지표를 통합하면 이 전략이 더 정확한 거래 신호를 생성하기 위해 각각의 강점을 최대한 활용할 수 있습니다.

슈퍼트렌드는 시장 소음을 필터링하고 과도한 거래를 피할 수 있습니다. DEMA는 일반적인 트렌드 방향을 결정하고 트렌드에 반대하는 거래를 방지 할 수 있습니다. 볼링거 밴드는 입상 및 스톱 손실에 대한 최적의 타이밍을 파악합니다.

모바일 알림은 적시에 거래 요청을 가능하게 합니다. 자동 스톱 손실 및 수익을 취하는 것은 수익을 잠금하고 손실을 줄일 수 있습니다.

위험 분석

여러 지표의 통합은 전략의 복잡성과 오류의 확률을 증가시킵니다. 지표 매개 변수 설정은 또한 거래 기회를 놓치거나 잘못된 신호를 생성 할 수 있습니다.

또한 과도한 공격적인 스톱 로스 설정은 손실을 증폭시킬 수 있습니다. 모바일 알림의 안정성은 또한 적시에 수익을 취하고 스톱 로스의 효과에 영향을 미칩니다.

최적화 방향

최적의 매개 변수 집합을 찾기 위해 다른 매개 변수 조합을 테스트 할 수 있습니다. 또한 매개 변수는 다른 시장 조건에 따라 조정 될 수 있습니다.

개별 지표의 독립적 인 사용 시도는 잘못된 신호를 줄일 수 있습니다. 추가적인 최적화를 위해 추가 지표도 추가 할 수 있습니다.

스톱 러스 (Stop Loss) 및 영업 취득 기준은 트래일링 스톱 러스 (Trailing Stop Loss) 및 부분 스톱 러스 (Partial Stop Loss) 등의 조정도 적용됩니다.

요약

이 전략은 무역 신호 생성에 대한 여러 기술적 지표의 강점을 결합하고 상대적으로 높은 실용성을 가지고 있습니다. 그러나 또한 특정 위험에 직면하고 있으며 효과적이고 수익성있게 사용하려면 지속적인 테스트와 최적화를 요구합니다.


/*backtest
start: 2024-01-23 00:00:00
end: 2024-02-22 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zhuenrong

//@version=4
strategy("Supertrend + DEMA + Bollinger Bands", overlay=true)

// 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")


// === Stop LOSS ===

if strategy.position_size>0
    strategy.exit("Stop Loss/Profit Long","Buy", stop=strategy.position_avg_price*100, limit=strategy.position_avg_price*1.1)
if strategy.position_size<0
    strategy.exit("Stop Loss/Profit Short","Sell", stop=strategy.position_avg_price*100, limit=strategy.position_avg_price*1.1)

더 많은