다중 시간대 확률적 추세 추종 거래 전략

EMA ATR MTF ROI TP SL
생성 날짜: 2025-02-18 17:53:04 마지막으로 수정됨: 2025-02-18 17:53:04
복사: 1 클릭수: 360
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

다중 시간대 확률적 추세 추종 거래 전략

개요

이 전략은 다중 시간 프레임 무작위 지표 ((Stochastic) 와 지수 이동 평균 ((EMA) 를 결합한 트렌드 추적 거래 시스템이다. 그것은 높은 시간 프레임 무작위 지표를 통해 과매매 과매매 조건을 판단하고, 동시에 EMA를 트렌드 필터로 사용하며, 동적 포지션 관리 및 스톱 손실 추적 기능을 통합하여, 완전한 거래 전략 시스템이다.

전략 원칙

이 전략의 핵심 논리는 다음과 같은 핵심 요소에 기반합니다.

  1. 고시계 무작위 지표를 사용하여 오버 바이 오버 세 영역을 식별하고, K선과 오버 바이 오버 세 레벨의 교차로 잠재적인 거래 신호를 결정합니다.
  2. EMA를 트렌드 필터로 사용하여, EMA 위에 있는 가격만 더하고, EMA 아래에 있는 가격만 더하지
  3. ATR의 동적 계산에 기초한 스톱 로즈와 수익 목표, 스톱 로즈의 거리는 ATR의 1.5배, 수익 목표의 2배입니다.
  4. 계정 리스크 비율에 기반한 동적 포지션 계산 방법을 사용하여 각 거래의 리스크를 기본 수준으로 제어합니다.
  5. 선택적 추적 중지 기능, 추적 거리는 1.5배 ATR

전략적 이점

  1. 다중 신호 확인: 고시계 무작위 지표와 EMA 트렌드 필터를 결합하여 신호 신뢰성을 향상시킵니다.
  2. 좋은 위험 관리: 백분율 위험 관리 방법을 사용하여 자금의 안전을 보장하십시오.
  3. 유연한 스톱 메커니즘: 고정 스톱 및 추적 스톱을 지원하여 다양한 시장 환경에 적응
  4. 명확한 거래 경고: 시스템이 자동으로 입점, 정지점, 목표점을 표시하여 거래 실행을 용이하게합니다.
  5. 동적 포지션 관리: 변동성에 따라 거래 규모를 자동으로 조정하여 자금 사용 효율을 최적화

전략적 위험

  1. 트렌드 리버스 위험: 시장의 격렬한 흔들림 속에서 잘못된 신호가 나타날 수 있다
  2. 슬라이드 리스크: 시장 유동성이 부족할 때 더 큰 슬라이드 위험에 직면할 수 있다.
  3. 매개 변수 민감성: 정책의 성능은 매개 변수 설정에 민감하며, 신중한 최적화가 필요합니다.
  4. 회수 위험: 시장의 급격한 변동으로 인해 더 큰 회수가 발생할 수 있습니다.
  5. 스톱 손실 트리거 위험: 스톱 손실을 추적하는 것은 변동이 심해지면 조기 트리거 될 수 있습니다.

전략 최적화 방향

  1. 시장 환경 필터를 추가: 변동률 지표 또는 트렌드 강도 지표를 추가하여 다른 시장 환경에서 전략 매개 변수를 조정할 수 있습니다.
  2. 최적화 신호 확인 메커니즘: 추가 거래량 확인 또는 다른 기술 지표를 보조 판단으로 고려할 수 있습니다.
  3. 포지션 관리를 개선: 시장의 변동성에 따라 리스크 비율을 조정할 수 있습니다.
  4. 개선된 스톱스 메커니즘: 시장 특성에 따라 동적으로 조정되는 스톱스 거리 추적
  5. 시간 필터를 추가: 중요한 시간 동안 거래 제한을 고려하여 중요한 뉴스 발표 기간 동안의 위험을 피하십시오.

요약하다

이 전략은 다중 시간 프레임 분석과 다중 신호 확인 메커니즘을 통해, 완벽한 위험 관리 시스템과 결합하여, 비교적 완전한 거래 시스템을 구축합니다. 위험이 있지만, 지속적인 최적화 및 개선으로, 이 전략은 다양한 시장 환경에서 안정적인 성능을 유지할 것으로 예상됩니다. 위험 감수성이 강하고 거래 경험이있는 투자자가 사용할 수 있습니다.

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

//@version=5
strategy("Ultimate fairas Oil", overlay=true)

// === Input Parameter ===
k_period = input(14, "K Period")
d_period = input(3, "D Period")
smooth_k = input(3, "Smooth K")
overbought = input(80, "Overbought Level")
oversold = input(20, "Oversold Level")
atrMult = input(1.5, "ATR Multiplier")
use_trailing_stop = input(true, "Enable Trailing Stop")
ema_length = input(50, "EMA Length")
risk_percent = input(2, "Risk per Trade (%)") / 100
account_balance = input(50000, "Account Balance")
mtf_tf = input.timeframe("D", "Higher Timeframe for Stochastic")

// === Multi-Timeframe Stochastic ===
stoch_source = request.security(syminfo.tickerid, mtf_tf, ta.stoch(close, high, low, k_period))
k = ta.sma(stoch_source, smooth_k)

// === Trend Filter (EMA) ===
ema = ta.ema(close, ema_length)
trendUp = close > ema
trendDown = close < ema

// === Entry Conditions ===
longCondition = ta.crossover(k, oversold) and trendUp
shortCondition = ta.crossunder(k, overbought) and trendDown

// === ATR-Based Stop Loss & Take Profit ===
atrValue = ta.atr(14)
stopLoss = atrMult * atrValue
takeProfit = 2 * stopLoss

// === Dynamic Lot Sizing (Risk Management) ===
risk_amount = account_balance * risk_percent
position_size = risk_amount / stopLoss

// === Trailing Stop Calculation ===
trailOffset = atrValue * 1.5
trailStopLong = use_trailing_stop ? close - trailOffset : na
trailStopShort = use_trailing_stop ? close + trailOffset : na

// === Execute Trades ===
if longCondition
    strategy.entry("Long", strategy.long, qty=position_size)
    strategy.exit("Exit Long", from_entry="Long", stop=close - stopLoss, limit=close + takeProfit, trail_points=use_trailing_stop ? trailOffset : na)

    // // Labels & Lines
    // label.new(x=bar_index, y=close, text="BUY", color=color.green, textcolor=color.white, size=size.small, style=label.style_label_down)
    // label.new(x=bar_index, y=close + takeProfit, text="TP 🎯", color=color.blue, textcolor=color.white, size=size.tiny)
    // label.new(x=bar_index, y=close - stopLoss, text="SL ❌", color=color.red, textcolor=color.white, size=size.tiny)
    // line.new(x1=bar_index, y1=close + takeProfit, x2=bar_index + 5, y2=close + takeProfit, width=2, color=color.blue)
    // line.new(x1=bar_index, y1=close - stopLoss, x2=bar_index + 5, y2=close - stopLoss, width=2, color=color.red)

    // Alert
    alert("BUY Signal! TP: " + str.tostring(close + takeProfit) + ", SL: " + str.tostring(close - stopLoss) + ", Lot Size: " + str.tostring(position_size), alert.freq_once_per_bar_close)

if shortCondition
    strategy.entry("Short", strategy.short, qty=position_size)
    strategy.exit("Exit Short", from_entry="Short", stop=close + stopLoss, limit=close - takeProfit, trail_points=use_trailing_stop ? trailOffset : na)

    // // Labels & Lines
    // label.new(x=bar_index, y=close, text="SELL", color=color.red, textcolor=color.white, size=size.small, style=label.style_label_up)
    // label.new(x=bar_index, y=close - takeProfit, text="TP 🎯", color=color.blue, textcolor=color.white, size=size.tiny)
    // label.new(x=bar_index, y=close + stopLoss, text="SL ❌", color=color.green, textcolor=color.white, size=size.tiny)
    // line.new(x1=bar_index, y1=close - takeProfit, x2=bar_index + 5, y2=close - takeProfit, width=2, color=color.blue)
    // line.new(x1=bar_index, y1=close + stopLoss, x2=bar_index + 5, y2=close + stopLoss, width=2, color=color.green)

    // Alert
    alert("SELL Signal! TP: " + str.tostring(close - takeProfit) + ", SL: " + str.tostring(close + stopLoss) + ", Lot Size: " + str.tostring(position_size), alert.freq_once_per_bar_close)