Bollinger Bands와 ATR 동적 손절매와 결합된 다중 지표 추세 추종 전략

BB MACD ADX ATR
생성 날짜: 2024-12-12 16:08:45 마지막으로 수정됨: 2024-12-12 16:08:45
복사: 0 클릭수: 446
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

Bollinger Bands와 ATR 동적 손절매와 결합된 다중 지표 추세 추종 전략

개요

이 전략은 부린 밴드, 트렌드 지표, 동력 지표 및 변동률 지표가 결합된 다기술 지표에 기반한 트렌드 추적 거래 시스템으로, 수량 가격 조합을 통해 거래 결정을 합니다. 이 전략은 부린 밴드 브레이크를 주요 입문 신호로 사용하고, ADX 트렌드 강도 확인 및 거래량 브레이크 검증을 결합하고, MACD 및 ATR 트레일링 스톱을 출구 메커니즘으로 사용합니다.

전략 원칙

전략의 핵심 논리는 다음과 같은 측면에 기초합니다.

  1. 부린 밴드 (Bollinger Bands) 를 기준으로 가격 변동의 범위를 사용하여, 가격이 상향 궤도를 돌파 할 때 더 많은 기회를 찾고, 하향 궤도를 돌파 할 때 더 적은 기회를 찾습니다
  2. ADX 지표로 트렌드 강도를 판단하고, 트렌드가 충분히 강할 때만 포지션을 개시합니다 (ADX>25)
  3. 거래량 발생량을 요구합니다 ((20일 평균의 1.5배 이상) 가격 돌파의 유효성을 확인합니다.
  4. 슈퍼 트렌드 지표를 사용하여 트렌드 방향을 필터링하여 가격이 트렌드 라인의 올바른 쪽에 있을 때만 포지션을 열고
  5. MACD 사각지대, ATR 이동 중지 또는 ADX 약화를 퇴출 조건으로 사용

전략적 이점

  1. 다중 신호의 조합은 거래의 정확성을 높여서 가짜 침입의 위험을 효과적으로 감소시킵니다.
  2. ADX와 거래량 확인을 통해 트렌드 거래의 승률을 높였습니다.
  3. 동적 스톱 (ATR trailing stop) 은 수익을 보호하면서 트렌드에 충분한 공간을 제공합니다.
  4. 트렌드 추적과 역전 전략의 장점을 결합하여 큰 트렌드를 포착할 수 있고 중요한 역전 기회를 놓치지 않습니다.
  5. 트렌드 강도 확인, 수량 조정 및 동적 상쇄를 포함한 철저한 위험 제어 장치

전략적 위험

  1. 불안한 시장에서 빈번한 가짜 신호가 발생하여 연속적인 정지 손실을 초래할 수 있습니다.
  2. 여러 조건의 중첩으로 인해 중요한 거래 기회를 놓칠 수 있습니다.
  3. ATR 상쇄는 급격한 변동이 발생하면 조기 상쇄될 수 있습니다.
  4. 트렌드의 지속성에 의존하고, 트렌드가 갑자기 돌아간다면 큰 반전이 발생할 수 있습니다.
  5. 전략의 유효성을 검증하기 위해 더 많은 표본이 필요합니다.

전략 최적화 방향

  1. 시장 환경 판단 메커니즘에 포함되는 것을 고려하고, 다른 시장 조건에서 다른 파라미터 조합을 사용합니다.
  2. 시간 필터를 도입하여 알려진 높은 파동 기간을 피할 수 있습니다.
  3. 스톱 패러미터를 최적화하여 다양한 변동률 환경에서 ATR 곱수를 동적으로 조정합니다.
  4. 거래량에 대한 분석의 깊이를 높이고, 거래량에 대한 품질을 고려하고, 수량만을 고려하지 않는다.
  5. 신호의 신뢰성을 높이기 위해 더 많은 시장 감정 지표를 추가하는 것을 고려할 수 있습니다.

요약하다

이것은 잘 설계된 다중 지표 트렌드 추적 전략으로, 부린 띠, ADX, 슈퍼 트렌드, MACD 등의 지표의 유기적 결합을 통해 트렌드 추적과 위험 통제를 겸비한 거래 시스템을 구축한다. 전략의 장점은 다중 신호 확인과 정교한 위험 제어 장치에 있다. 그러나 동시에 과도한 최적화와 변수 민감성의 도전에 직면한다. 지속적인 최적화와 시장 환경의 동적 적응을 통해, 이 전략은 다양한 시장 환경에서 안정적인 성능을 유지할 것으로 예상된다.

전략 소스 코드
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Nifty Options Trendy Markets with TSL", overlay=true)
// Input Parameters
lengthBB = input(20, title="Bollinger Bands Length")
multBB = input(2.0, title="Bollinger Bands Multiplier")
adxLength = input(14, title="ADX Length")
adxThreshold = input(25, title="ADX Entry Threshold")
adxExitThreshold = input(20, title="ADX Exit Threshold")
superTrendLength = input(10, title="Supertrend Length")
superTrendMultiplier = input(3.0, title="Supertrend Multiplier")
macdFast = input(12, title="MACD Fast Length")
macdSlow = input(26, title="MACD Slow Length")
macdSignal = input(9, title="MACD Signal Length")
atrLength = input(14, title="ATR Length")
atrMultiplier = input(1.5, title="Trailing Stop ATR Multiplier")
volumeSpikeMultiplier = input(1.5, title="Volume Spike Multiplier")

// Calculations
[macdLine, signalLine,_ ] = ta.macd(close, macdFast, macdSlow, macdSignal)
macdCrossover = ta.crossover(macdLine, signalLine)
macdCrossunder = ta.crossunder(macdLine, signalLine)
[middleBB,upperBB,lowerBB] = ta.bb(close, lengthBB, multBB)
[supertrend, direction]  = ta.supertrend(superTrendMultiplier,superTrendLength)
len = input.int(17, minval=1, title="DI Length")
lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50)
[diplus, diminus, adx] = ta.dmi(len, lensig)
atr = ta.atr(atrLength)
trailingStopLong = close - atr * atrMultiplier // For long trades
trailingStopShort = close + atr * atrMultiplier // For short trades
volumeSpike = volume > ta.sma(volume, 20) * volumeSpikeMultiplier

// Entry Conditions
longEntry = ta.crossover(close, upperBB) and adx > adxThreshold and volumeSpike and close > supertrend
shortEntry = ta.crossunder(close, lowerBB) and adx > adxThreshold and volumeSpike and close < supertrend

// Exit Conditions
longExit = ta.crossunder(macdLine, signalLine) or close < trailingStopLong or adx < adxExitThreshold
shortExit = ta.crossover(macdLine, signalLine) or close > trailingStopShort or adx < adxExitThreshold

// Strategy Entries and Exits
if (longEntry)
    strategy.entry("Long", strategy.long)
if (shortEntry)
    strategy.entry("Short", strategy.short)
if (longExit)
    strategy.close("Long")
if (shortExit)
    strategy.close("Short")

// Plotting
plot(supertrend, color=color.blue, style=plot.style_line, linewidth=2, title="Supertrend Line")
plot(trailingStopLong, title="Trailing Stop for Long", color=color.green, style=plot.style_line)
plot(trailingStopShort, title="Trailing Stop for Short", color=color.red, style=plot.style_line)
bgcolor(longEntry ? color.new(color.green, 90) : shortEntry ? color.new(color.red, 90) : na, title="Background for Entry")

// Alerts
alertcondition(longEntry, title="Long Entry", message="Buy Call: Long entry conditions met")
alertcondition(shortEntry, title="Short Entry", message="Buy Put: Short entry conditions met")
alertcondition(longExit, title="Long Exit", message="Exit Call: Long exit conditions met")
alertcondition(shortExit, title="Short Exit", message="Exit Put: Short exit conditions met")