다중 이동 평균 추세 추적 및 동적 손절매 전략

EMA RSI
생성 날짜: 2025-02-10 14:23:43 마지막으로 수정됨: 2025-02-10 14:23:43
복사: 4 클릭수: 389
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

다중 이동 평균 추세 추적 및 동적 손절매 전략

개요

이 전략은 다중 지수 이동 평균 (EMA) 과 상대적으로 약한 지표 (RSI) 를 기반으로 한 트렌드 추적 거래 시스템입니다. 전략은 일계 레벨의 EMA (20, 30, 200) 교차 신호, RSI 동력 확인 및 동적 스톱 메커니즘을 결합하여 시장의 장기적인 트렌드 기회를 잡기 위해 고안되었습니다.

전략 원칙

전략의 핵심 논리에는 다음과 같은 핵심 구성 요소가 포함됩니다.

  1. 입시 신호: 당일 라인 20일 EMA는 상향으로 30일 EMA를 가로질러, 가격이 200일 EMA 위에 있고, 동시에 RSI가 50보다 크면, 시스템은 다중 신호를 생성한다.
  2. 정지설정: 입구에 들어가면 50%의 고정 정지설정.
  3. 동적 스톱: 25%의 동적 추적 스톱을 사용하여 가격 혁신이 높을 때 스톱 위치를 이동합니다.
  4. 퇴출 메커니즘: 가격이 스톱 포즈 또는 트래킹 스톱 로즈 지점을 만지면 자동으로 청산하여 거래를 종료한다.

전략적 이점

  1. 다중 시간 주기의 검증: 일선 레벨의 평평선 조합을 통해 단기 변동성을 필터링하여 거래 안정성을 높인다.
  2. 동적 위험 관리: 손실을 추적하는 스톱 메커니즘은 수익을 효과적으로 잠금화하여 큰 철수를 피할 수 있습니다.
  3. 트렌드 확인이 충분하다: RSI 지표는 평균선 시스템과 결합하여 트렌드의 유효성을 더 잘 확인할 수 있다.
  4. 실행 논리 명확성: 입출장 조건이 명확하고, 이해하기 쉽고 동작하기 쉽다.

전략적 위험

  1. 흔들림 시장 위험: 가로판 흔들림 시장에서 자주 중지 손실을 유발할 수 있습니다.
  2. 슬라이드 포인트 영향: 시장이 급격하게 변동할 때, 동적 스톱로즈와 스톱 포스트는 큰 슬라이드 포인트에 직면할 수 있다.
  3. 가짜 뚫림 위험: 평선 교차 신호가 가짜 뚫림이 발생할 수 있다.
  4. 변수 민감성: 스톱 손실과 스톱 스톱 비율의 설정은 전략 성능에 큰 영향을 미칩니다.

전략 최적화 방향

  1. 시장 환경 필터: 시장 환경을 판단하기 위해 변동률 지표 (ATR와 같은) 를 추가할 수 있으며, 불안정한 시장에서 포지션을 줄이거나 거래를 중단할 수 있다.
  2. 정지율 동적화: 시장의 변동에 따라 정지율을 동적으로 조정하는 것을 고려한다.
  3. 입구 신호 최적화: 반전량 지표가 도입되어 평선 교차 신호와 함께 신호 신뢰도를 높일 수 있다.
  4. 포지션 관리 개선: 동적 포지션 관리 메커니즘을 도입하여 시장 위험도에 따라 포지션 규모를 자동으로 조정한다.

요약하다

이 전략은 다중 기술 지표의 협동 협동으로 완전한 트렌드 추적 거래 시스템을 구축한다. 전략의 주요 특징은 중·장기 트렌드 판단과 동적 위험 제어를 결합하여 트렌드가 명확한 시장 환경에서 작동하는 것이 좋다. 지속적인 최적화 및 개선으로 전략은 실제 거래에서 더 나은 성능을 기대한다.

전략 소스 코드
/*backtest
start: 2024-02-10 00:00:00
end: 2025-02-09 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Talbuaia Signal", overlay=true)

// Request EMAs on the daily timeframe
ema20_daily = request.security(syminfo.tickerid, "D", ta.ema(close, 20), lookahead=barmerge.lookahead_on)
ema30_daily = request.security(syminfo.tickerid, "D", ta.ema(close, 30), lookahead=barmerge.lookahead_on)
ema200_daily = request.security(syminfo.tickerid, "D", ta.ema(close, 200), lookahead=barmerge.lookahead_on)

// RSI Calculation
rsi = ta.rsi(close, 14)

// Plot daily EMAs
plot(ema20_daily, color=color.blue, title="Daily EMA 20")
plot(ema30_daily, color=color.orange, title="Daily EMA 30")
plot(ema200_daily, color=color.red, title="Daily EMA 200")

// Plot RSI
hline(50, "RSI Midline", color=color.gray)
plot(rsi, color=color.purple, title="RSI")

// Entry condition: 20 EMA crosses above 30 EMA, price is above 200 EMA, and RSI > 50
bullishEntry = ta.crossover(ema20_daily, ema30_daily) and close > ema200_daily and rsi > 50

// Variables to track entry price, take profit, and trailing stop
var float entryPriceLong = na
var float highestPriceSinceEntry = na
var float takeProfitLevel = na
var float trailingStopLevel = na

// Entry Logic
if bullishEntry
    strategy.entry("Long", strategy.long)
    entryPriceLong := close
    highestPriceSinceEntry := close  // Initialize the highest price since entry
    takeProfitLevel := entryPriceLong * 1.50  // Set take profit at 50% above entry price
    trailingStopLevel := na  // Reset trailing stop
    label.new(bar_index, close, "BUY", style=label.style_label_up, color=color.green, textcolor=color.white)

// Update highest price and trailing stop dynamically
if strategy.position_size > 0
    highestPriceSinceEntry := math.max(highestPriceSinceEntry, close)  // Track the highest price reached
    trailingStopLevel := highestPriceSinceEntry * (1 - 0.25)  // Set trailing stop at 25% below the highest price

// Exit Logic: Take profit or trailing stop
if strategy.position_size > 0 and (close >= takeProfitLevel or close <= trailingStopLevel)
    strategy.close("Long")
    label.new(bar_index, close, "EXIT LONG", style=label.style_label_down, color=color.red, textcolor=color.white)

// Plot trailing stop and take profit levels on the chart
plot(trailingStopLevel, "Trailing Stop", color=color.red, linewidth=2, style=plot.style_line)
plot(takeProfitLevel, "Take Profit", color=color.green, linewidth=2, style=plot.style_line)