듀얼 체인 하이브리드 모멘텀 이동 평균 추종 트레이딩 시스템

EMA MA
생성 날짜: 2024-11-29 17:04:57 마지막으로 수정됨: 2024-11-29 17:04:57
복사: 5 클릭수: 465
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

듀얼 체인 하이브리드 모멘텀 이동 평균 추종 트레이딩 시스템

개요

이 전략은 지수 이동 평균 ((EMA) 에 기반한 혁신적인 거래 시스템으로, 서로 다른 시간 주기에 두 개의 독립적인 거래 사슬을 설정하여 시장 기회를 포착합니다. 이 전략은 장기 트렌드 추적과 단기 운동 거래의 장점을 통합하여 주, 일, 12 시간 및 9 시간 등의 여러 시간 주기에 EMA를 교차하여 거래 신호를 생성하여 시장의 다차원 분석과 파악을 가능하게합니다.

전략 원칙

이 전략은 두 개의 체인 디자인을 사용하며, 각각의 체인에는 고유한 출전 논리가 있습니다:

链1 (장기 경향) 은 주경선과 일계주기를 사용한다:

  • 입시 신호: 종착 가격이 회선 주기 상의 EMA를 통과할 때 발생하는 다중 신호
  • 출구 신호: 종착 가격이 일선 주기 아래의 EMA를 통과할 때 평점 신호가 발생
  • 기본 EMA 주기는 10이고 필요에 따라 조정할 수 있습니다.

链条2 (短期动量) 는 12시간과 9시간의 주기를 사용한다:

  • 입시 신호: 12 시간 주기 상의 EMA를 마감할 때 발생하는 다중 신호
  • 출구 신호: 9 시간 주기 상의 EMA를 통과할 때 청산 신호가 발생
  • 기본 EMA 주기는 9이며 필요에 따라 조정할 수 있습니다.

전략적 이점

  1. 다차원 시장 분석: 다양한 시기를 조합하여 시장의 흐름을 전체적으로 파악합니다.
  2. 유연성: 두 개의 체인은 독립적으로 활성화 또는 비활성화되어 다른 거래 스타일에 적합합니다.
  3. 위험 제어: 여러 시간 주기 확인을 사용하여 잘못된 신호의 위험을 줄입니다.
  4. 파라미터가 조정 가능: EMA 사이클과 시간 사이클은 필요에 따라 수정할 수 있다
  5. 응답 기능 개량: 정책 검증 및 최적화를 위해 응답 중 설정

전략적 위험

  1. 추세 전환 위험: 급격한 변동 시장에서 지연될 수 있습니다.
  2. 시간주기 구성 위험: 다른 시장에는 다른 시간주기 조합이 필요할 수 있습니다.
  3. 매개 변수 최적화 위험: 과도한 최적화가 과부응으로 이어질 수 있다
  4. 신호 중복 위험: 두 개의 사슬이 동시에 촉발되면 포지션의 위험이 증가할 수 있습니다.

위험 관리 제안:

  • 합리적인 Stop Loss을 설정하세요.
  • 시장 특성에 따라 변수를 조정
  • 실판 전에 충분한 피드백 검증
  • 각 거래에 대한 자본 비율을 제어합니다.

전략 최적화 방향

  1. 신호 필터링 최적화:
  • 볼륨 확인 메커니즘 추가
  • 변동률 지표 필터링 신호를 도입
  • 증가 추세 강도 확인
  1. 위험 관리 최적화:
  • 역동적 상쇄 메커니즘 개발
  • 포지션 관리 시스템 설계
  • 추가된 회수 제어 기능
  1. 시간주기 최적화:
  • 최적의 시간주기 조합을 연구합니다.
  • 적응 시간 주기 메커니즘 개발
  • 시장 상태 인식 기능을 추가합니다.

요약하다

이중 체인 혼합량 평행선 추적 거래 시스템은 긴 단기 평행선 전략을 혁신적으로 결합하여 시장의 다차원 분석과 파악을 구현합니다. 시스템 설계는 유연하며, 다른 시장 상황과 거래자의 스타일에 따라 조정할 수 있으며, 강력한 실용성을 가지고 있습니다. 합리적인 위험 제어와 지속적인 최적화를 통해이 전략은 실제 거래에서 안정적인 수익을 얻을 수 있습니다. 거래자는 실제 사용 전에 충분한 재검토와 변수 최적화를 수행하여 최적의 거래 효과를 얻을 수 있습니다.

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

//@version=5
strategy(title='Dual Chain Strategy', shorttitle='DualChain', overlay=true)

// User inputs for enabling/disabling chains
enableChain1 = input.bool(true, title='Enable Chain 1')
enableChain2 = input.bool(true, title='Enable Chain 2')

// User inputs for the first chain
len1 = input.int(10, minval=1, title='Length Chain 1 EMA', group="Chain 1")
src1 = input(close, title='Source Chain 1', group="Chain 1")
tf1_entry = input.timeframe("W", title='Chain 1 Entry Timeframe', group="Chain 1")
tf1_exit = input.timeframe("D", title='Chain 1 Exit Timeframe', group="Chain 1")

// Weekly timeframe EMA for Chain 1
entryEMA1 = request.security(syminfo.tickerid, tf1_entry, ta.ema(src1, len1))

// Daily timeframe EMA for Chain 1
exitEMA1 = request.security(syminfo.tickerid, tf1_exit, ta.ema(src1, len1))

// User inputs for the second chain
len2 = input.int(9, minval=1, title='Length Chain 2 EMA', group="Chain 2")
src2 = input(close, title='Source Chain 2', group="Chain 2")
tf2_entry = input.timeframe("720", title='Chain 2 Entry Timeframe (12H)', group="Chain 2")  // 12 hours
tf2_exit = input.timeframe("540", title='Chain 2 Exit Timeframe (9H)', group="Chain 2")    // 9 hours

// Entry timeframe EMA for Chain 2
entryEMA2 = request.security(syminfo.tickerid, tf2_entry, ta.ema(src2, len2))

// Exit timeframe EMA for Chain 2
exitEMA2 = request.security(syminfo.tickerid, tf2_exit, ta.ema(src2, len2))

// Plotting Chain 1 EMAs
plot(enableChain1 ? entryEMA1 : na, title='Chain 1 Entry EMA', color=color.new(color.blue, 0))
plot(enableChain1 ? exitEMA1 : na, title='Chain 1 Exit EMA', color=color.new(color.yellow, 0))

// Plotting Chain 2 EMAs
plot(enableChain2 ? entryEMA2 : na, title='Chain 2 Entry EMA', color=color.new(color.green, 0))
plot(enableChain2 ? exitEMA2 : na, title='Chain 2 Exit EMA', color=color.new(color.red, 0))

// Backtesting period
startDate = input(timestamp('2015-07-27'), title="StartDate")
finishDate = input(timestamp('2026-01-01'), title="FinishDate")
time_cond = true

// Entry Condition (Chain 1)
bullishChain1 = enableChain1 and ta.crossover(src1, entryEMA1)
bearishChain1 = enableChain1 and ta.crossunder(src1, entryEMA1)

// Exit Condition (Chain 1)
exitLongChain1 = enableChain1 and ta.crossunder(src1, exitEMA1)
exitShortChain1 = enableChain1 and ta.crossover(src1, exitEMA1)

// Entry Condition (Chain 2)
bullishChain2 = enableChain2 and ta.crossover(src2, entryEMA2)
bearishChain2 = enableChain2 and ta.crossunder(src2, entryEMA2)

// Exit Condition (Chain 2)
exitLongChain2 = enableChain2 and ta.crossunder(src2, exitEMA2)
exitShortChain2 = enableChain2 and ta.crossover(src2, exitEMA2)

// Debugging: Plot entry signals for Chain 1
plotshape(bullishChain1, color=color.new(color.green, 0), style=shape.labelup, text='BUY C1', location=location.belowbar)
plotshape(bearishChain1, color=color.new(color.red, 0), style=shape.labeldown, text='SELL C1', location=location.abovebar)

// Debugging: Plot entry signals for Chain 2
plotshape(bullishChain2, color=color.new(color.green, 0), style=shape.labelup, text='BUY C2', location=location.belowbar)
plotshape(bearishChain2, color=color.new(color.red, 0), style=shape.labeldown, text='SELL C2', location=location.abovebar)

// Trade Execution for Chain 1
if bullishChain1 and time_cond
    strategy.entry('BUY_Chain_1', strategy.long)

if bearishChain1 and time_cond
    strategy.entry('SELL_Chain_1', strategy.short)

// Exit trades based on daily conditions for Chain 1
if exitLongChain1 and strategy.opentrades > 0
    strategy.close(id='BUY_Chain_1', when=exitLongChain1)

if exitShortChain1 and strategy.opentrades > 0
    strategy.close(id='SELL_Chain_1', when=exitShortChain1)

// Trade Execution for Chain 2
if bullishChain2 and time_cond
    strategy.entry('BUY_Chain_2', strategy.long)

if bearishChain2 and time_cond
    strategy.entry('SELL_Chain_2', strategy.short)

// Exit trades based on daily conditions for Chain 2
if exitLongChain2 and strategy.opentrades > 0
    strategy.close(id='BUY_Chain_2', when=exitLongChain2)

if exitShortChain2 and strategy.opentrades > 0
    strategy.close(id='SELL_Chain_2', when=exitShortChain2)

// Close all positions outside the backtesting period
if not time_cond
    strategy.close_all()