동적 이중 EMA 트레일링 스톱 전략

저자:차오장, 날짜: 2024-01-24 15:13:07
태그:

img

전반적인 설명

이 전략은 기하급수적인 이동 평균 (EMA) 을 사용하여 잠재적 인 트렌드 역전 또는 계속성을 이용하고 Chande 동적 컨버전스 디버전스 (CDC) 평균 진정한 범위 방법을 기반으로 트레일링 스톱을 이용하는 것을 목표로합니다. 이 전략은 입시 시기를 결정하기 위해 여러 지표를 결합하고 새로운 트렌드를 포착하는 동안 위험을 제어하기 위해 시장 변동성에 기반한 스톱 손실 및 수익 수준을 설정합니다.

전략 논리

이 전략은 트렌드 방향을 결정하기 위해 60주기 및 90주기 이중 EMA를 사용합니다. 짧은 기간 EMA가 더 긴 기간 EMA 위에 이동하는 크로스오버는 상승 신호를 제공합니다. 동시에, 신호 라인의 위의 MACD 라인 크로스오버는 상승 견해를 확인 할 수 있습니다. 엔트리는 가격이 이전에 계산된 CDC 트레일링 스톱 레벨보다 높아야합니다.

출구 규칙은: 가격이 ATR 기반의 영업 수익 수준을 달성하거나 CDC 후속 스톱 로스 수준을 넘어지면 포지션을 닫습니다.

이점 분석

이 전략은 주요 트렌드 방향을 판단하기 위해 이중 EMA와 MACD를 결합하여 입력 시기를 확인하고 잘못된 브레이크오웃을 피합니다. 후속 스톱과 이익 목표 수준은 모두 효과적인 리스크 관리를 위해 시장 변동성에 따라 계산됩니다. 추세가 역전되거나 계속되는 경우에도이 전략은 적시에 기회를 잡을 수 있습니다.

또한, 이 전략의 입력 매개 변수는 사용자 정의 가능합니다. 사용자는 자신의 거래 스타일에 따라 EMA 기간, ATR 기간 및 CDC 곱셈을 조정할 수 있습니다.

위험 분석

이 전략의 가장 큰 위험은 잘못된 트렌드 판단이다. 시장이 통합 될 때 EMA는 쉽게 잘못된 신호를 줄 수 있다. 이 시점에서 MACD의 확인 역할은 특히 중요하다. 또한 갑작스러운 사건으로 인한 큰 가격 격차를 처리하기 위해 CDC 스톱 로스 멀티플리커를 적절히 증가시키는 것이 필요하다.

최적화 방향

  1. 최적의 설정을 찾기 위해 EMA 기간 매개 변수의 다른 조합을 테스트합니다.
  2. 다른 CDC 스톱 로스 곱셈 크기를 테스트합니다.
  3. 입력 시기를 필터링하기 위해 다른 지표를 통합 시도
  4. 갑작스러운 시장 이벤트를 처리하는 메커니즘을 추가합니다.

요약

이 전략은 유가증권에서 잠재적 인 기회를 식별하기 위해 트렌드 및 변동성 지표의 장점을 잘 활용합니다. 매개 변수 최적화 및 메커니즘 개선을 통해이 전략은 안정성과 수익성을 더욱 향상시킬 잠재력을 가지고 있습니다. 양적 거래자에게 신뢰할 수 있고 확장 가능한 전략적 틀을 제공합니다.


/*backtest
start: 2023-01-17 00:00:00
end: 2024-01-23 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Improved EMA & CDC Trailing Stop Strategy", overlay=true)

// Define the inputs
ema60Period = input(60, title="EMA 60 Period")
ema90Period = input(90, title="EMA 90 Period")
atrPeriod = input(24, title="CDC ATR Period")
multiplier = input(4.0, title="CDC Multiplier")
profitTargetMultiplier = input(2.0, title="Profit Target Multiplier (ATR)")

// Calculate EMAs
ema60 = ta.ema(close, ema60Period)
ema90 = ta.ema(close, ema90Period)

// Calculate ATR 
atr = ta.atr(atrPeriod)

// MACD calculation
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)

// Define the trailing stop and profit target
longStop = close - multiplier * atr
shortStop = close + multiplier * atr
longProfitTarget = close + profitTargetMultiplier * atr
shortProfitTarget = close - profitTargetMultiplier * atr

// Entry conditions
longCondition = close > ema60 and ema60 > ema90 and macdLine > signalLine and close > longStop
shortCondition = close < ema60 and ema60 < ema90 and macdLine < signalLine and close < shortStop

// Exit conditions based on profit target
longProfitCondition = close >= longProfitTarget
shortProfitCondition = close <= shortProfitTarget

// Plot the EMAs, Stops, and MACD for visualization
plot(ema60, color=color.blue, title="60 EMA")
plot(ema90, color=color.red, title="90 EMA")
plot(longStop, color=color.green, title="Long Stop", style=plot.style_linebr)
plot(shortStop, color=color.red, title="Short Stop", style=plot.style_linebr)
hline(0, "Zero Line", color=color.gray)
plot(macdLine - signalLine, color=color.blue, title="MACD Histogram")

// Strategy execution using conditional blocks
if longCondition
    strategy.entry("Long", strategy.long)
if shortCondition
    strategy.entry("Short", strategy.short)

// Exit based on profit target and trailing stop
if longProfitCondition or close < longStop
    strategy.close("Long")
if shortProfitCondition or close > shortStop
    strategy.close("Short")



더 많은