다중 시계열 추세 식별 유형 적응형 동적 위치 조정 전략

DEMA ATR supertrend
생성 날짜: 2025-02-24 09:48:55 마지막으로 수정됨: 2025-02-27 16:49:07
복사: 5 클릭수: 433
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

다중 시계열 추세 식별 유형 적응형 동적 위치 조정 전략 다중 시계열 추세 식별 유형 적응형 동적 위치 조정 전략

개요

이 전략은 슈퍼트렌드와 이중 지수 이동 평균 (DEMA) 을 기반으로 한 트렌드 추적 거래 시스템이다. 이 전략은 슈퍼트렌드 지표의 트렌드 방향 식별 능력과 DEMA의 트렌드 확인 기능을 결합하여 신뢰할 수 있는 거래 의사 결정 프레임워크를 구축한다. 이 시스템은 양방향 거래를 지원하며, 포지션 동적 조정 메커니즘을 갖추고 있으며, 시장 환경에 따라 다중 허공 방향을 유연하게 전환할 수 있다.

전략 원칙

전략의 핵심 논리는 다음과 같은 핵심 구성 요소를 기반으로 합니다.

  1. 슈퍼트렌드 지표: ATR 주기를 이용하여 10으로 설정하고, 인수값은 3.0으로, 가격 트렌드를 잡기 위한 전환점.
  2. DEMA 지표: 100주기의 이중 지수 이동 평균을 사용하여 시장 소음을 필터링하고 트렌드를 확인하는 신뢰성을 사용합니다.
  3. 거래 신호 생성 메커니즘:
    • 다중 신호: 가격이 수퍼트렌드를 넘어서 DEMA 상위에서 마감할 때 트리거
    • 허공 신호: 가격이 수퍼트렌드를 넘어서 DEMA 아래에서 마감할 때 트리거
  4. 포지션 관리: 시스템은 직접 포지션 개설, 반수 및 포지션 조작을 포함한 유연한 포지션 조정을 지원한다.

전략적 이점

  1. 다중 확인 메커니즘: 슈퍼트렌드와 DEMA 두 지표를 조합하여 거래 신호의 신뢰도를 크게 향상시킵니다.
  2. 유연한 포지션 관리: 다방면 양방향 거래를 지원하고, 시장 상황에 따라 포지션 방향을 동적으로 조정할 수 있다.
  3. 리스크 관리가 완벽하다: 트렌드 전환점에서 신속한 대응 장치가 있으며, 새로운 트렌드 기회를 잡을 수 있습니다.
  4. 매개 변수 조정성: ATR 주기, Supertrend 인자 및 DEMA 주기와 같은 핵심 매개 변수는 시장 특성에 따라 최적화 할 수 있습니다.

전략적 위험

  1. 수평 시장의 부실한 성능: 시장 환경이 명확한 경향을 보이지 않는 상황에서 빈번한 가짜 브레이크 신호가 발생할 수 있습니다.
  2. 지연 위험: DEMA를 필터로 사용하는 것은 출입 시기를 약간 지연시켜 수익의 일부를 좌우할 수 있다.
  3. 매개 변수 민감성: 전략 효과는 매개 변수 설정에 민감하며, 다른 시장 환경에는 다른 매개 변수 조합이 필요할 수 있다.

전략 최적화 방향

  1. 그리고, 그 다음에는, 변동율 적응 장치를 도입합니다.
    • 시장의 변동에 따라 수퍼트렌드 인수값을 동적으로 조정합니다.
    • 높은 변동 동안 필터 밸브 을 높이고 낮은 변동 동안 적절한 완화 조건
  2. 시장 환경 인식 모듈을 추가합니다:
    • 트렌드 강도 지표를 추가하여 수평 시장에서 거래 빈도를 낮추는 것
    • 거래량 지표의 도입은 돌파구 유효성을 확인하는 보조입니다.
  3. 손절매 메커니즘 개선:
    • ATR 기반의 동적 정지
    • 이윤을 보호하기 위해 모바일 중지 기능을 추가합니다.

요약하다

이 전략은 Supertrend와 DEMA 지표를 능숙하게 결합하여 안정적인 트렌드 추적 시스템을 구축한다. 이 전략의 장점은 신호 신뢰도가 높고 위험 관리가 완벽하지만 여전히 거래자가 특정 시장 특성에 따라 매개 변수를 최적화해야 한다는 것이다. 제안된 최적화 방향으로 전략의 적응성과 안정성이 더욱 향상될 것으로 보인다.

전략 소스 코드
/*backtest
start: 2025-02-16 00:00:00
end: 2025-02-23 00:00:00
period: 5m
basePeriod: 5m
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/

//@version=6
strategy("Supertrend with DEMA Strategy (Reversal Enabled)", overlay=true)

// ===== Parameters for Supertrend =====
atrPeriod = input.int(10, "ATR Length", minval=1)
factor    = input.float(3.0, "Factor", minval=0.01, step=0.01)

// ===== Parameters for Allowing Trade Directions =====
allowLong  = input.bool(true,  "Allow LONG")
allowShort = input.bool(true,  "Allow SHORT")

// Supertrend Calculation
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
// Set the value to na for the first bar to avoid false signals
supertrend := barstate.isfirst ? na : supertrend

// Plot Supertrend Lines
plot(direction < 0 ? supertrend : na, "Up Trend",   color=color.green, style=plot.style_linebr)
plot(direction < 0 ? na : supertrend, "Down Trend", color=color.red,   style=plot.style_linebr)

// ===== Parameters and Calculation for DEMA =====
demaLength = input.int(100, "DEMA Length", minval=1)
e1 = ta.ema(close, demaLength)
e2 = ta.ema(e1, demaLength)
dema = 2 * e1 - e2

// Plot DEMA
plot(dema, "DEMA", color=#43A047)

// ===== Signal Definitions =====
// Basic Supertrend Trend Change Signals
trendUp   = ta.crossover(close, supertrend)
trendDown = ta.crossunder(close, supertrend)

// Entry Signals considering DEMA
longSignal  = trendUp and (close > dema)
shortSignal = trendDown and (close < dema)

// ===== Entry/Exit Logic =====

// LONG Signal
if (longSignal)
    // If there is an open SHORT position – reverse it to LONG if allowed
    if (strategy.position_size < 0)
        if (allowLong)
            strategy.close("Short")
            strategy.entry("Long", strategy.long)
        else
            // If reversal to LONG is not allowed – just close SHORT
            strategy.close("Short")
    // If there is no position – open LONG if allowed
    else if (strategy.position_size == 0)
        if (allowLong)
            strategy.entry("Long", strategy.long)

// SHORT Signal
if (shortSignal)
    // If there is an open LONG position – reverse it to SHORT if allowed
    if (strategy.position_size > 0)
        if (allowShort)
            strategy.close("Long")
            strategy.entry("Short", strategy.short)
        else
            // If reversal to SHORT is not allowed – just close LONG
            strategy.close("Long")
    // If there is no position – open SHORT if allowed
    else if (strategy.position_size == 0)
        if (allowShort)
            strategy.entry("Short", strategy.short)

// ===== Additional Position Closure on Trend Change without Entry =====
// If Supertrend crosses (trend change) but DEMA conditions are not met,
// close the opposite position if open.
if (trendUp and not longSignal and strategy.position_size < 0)
    strategy.close("Short")

if (trendDown and not shortSignal and strategy.position_size > 0)
    strategy.close("Long")