RSI 필터와 ATR 위험 관리를 활용한 다중 시간대 추세 돌파 전략

EMA RSI ATR Trend Filter POSITION SIZING risk management
생성 날짜: 2025-04-24 16:55:42 마지막으로 수정됨: 2025-04-24 16:55:42
복사: 3 클릭수: 319
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

RSI 필터와 ATR 위험 관리를 활용한 다중 시간대 추세 돌파 전략 RSI 필터와 ATR 위험 관리를 활용한 다중 시간대 추세 돌파 전략

개요

이 전략은 트렌드 추적과 브레이크 트레이드를 결합한 다중 시간 프레임 전략으로, 트렌드 필터로 EMA 크로스, 동력 확인 지표로 RSI, ATR으로 동적 위험 관리를 수행한다. 이 전략은 분리된 경보 시스템을 통해 정확한 입출소 신호 관리를 구현하고, 비율 기반의 자금 관리 방법을 사용하여 위험을 통제한다.

전략 원칙

  1. 추세 결정: 빠른 EMA ((9) 와 느린 EMA ((21) 의 교차 관계를 사용하여 시장 경향 방향을 판단하십시오. EMA9가 EMA21을 통과하면 상승 추세로 판단되며 반대로 하향 추세입니다.
  2. 동력 확인: RSI 지표 ((주기 14) 를 통해 트렌드 강도를 확인, 멀티 헤드 거래는 RSI> 50을 요구하고, 공백 거래는 RSI<50을 요구한다.
  3. 브레이크 신호: 트렌드 방향을 확인한 후, 가격이 전 K 선의 하위/고위 지점을 돌파할 때 거래 신호가 발생한다.
  4. 위험 관리: ATR ((주기 14) 를 사용하여 동적 스톱로스를 계산하고, 고정 위험 비율은 계좌 적당금의 2%이다. 스톱로스는 스톱로스 거리의 3배로 설정하고, 50%의 수익을 달성한 후 스톱로스를 추적하기 시작합니다.
  5. 포지션 계산포지션 크기는 스톱 로드 거리 및 리스크 비율에 따라 동적으로 계산되며, 각 거래의 위험이 일치하도록 합니다.

우위 분석

  1. 다중 인자 검증트렌드, 동력 및 가격 행동의 3차원 확인을 결합하여 신호 품질을 향상시킵니다.
  2. 동적 위험 관리ATR-based Stop Loss: ATR-based Stop Loss은 시장의 변동성에 적응하고, 상동 수익을 보호하기 위해 Stop Loss을 추적합니다.
  3. 과학 자금 관리: 고정 비율 위험 제어 과도한 거래를 피하고, 포지션 계산은 위험 선호를 정확하게 일치한다.
  4. 명확한 시각적 신호: 플롯셰이프 함수를 통해 거래 신호를 직관적으로 표시하고, 모니터링을 용이하게 한다.
  5. 분리 경보 시스템: 독립적인 포지션 개시/무소 포지션 경보가 자동화 된 거래 을 가능하게 한다.

위험 분석

  1. 변동성 있는 시장의 위험: 추세가 명확하지 않은 회수 상황에서 연속적인 가짜 브레이크 신호가 발생할 수 있습니다. 해결책은 ADX와 같은 추세 강도 필터를 추가하는 것입니다.
  2. 매개 변수 민감 위험: 고정된 매개 변수는 다른 품종이나 시장 환경에서 작동하지 않을 수 있으며, 매개 변수 최적화 또는 적응 매개 변수 설정을 권장한다.
  3. 비행기의 위험성가격 폭등으로 인해 점유율이 확대될 수 있으며, 실제 정지수행 가격은 예상과 일치하지 않습니다. 중요한 데이터가 공개되기 전에 포지션을 낮추거나 거래를 중지하는 것이 해결책입니다.
  4. 과도한 적합성의 위험: 역사적인 데이터에 기반한 최적화된 파라미터는 미래에 유효하지 않을 수 있으며, 충분한 전향 테스트를 실시해야 한다.

최적화 방향

  1. 적응 변수: 고정된 파라미터를 변동률이나 시장 상태에 기반한 자율적 파라미터로 바꾸어, ATR 비율을 사용하여 EMA 주기를 설정한다.
  2. 복합 트렌드 필터: 더 높은 시간 프레임의 트렌드 확인을 포함합니다. 예를 들어 일선 트렌드와 시간선 신호를 동시에 충족하기 위해 거래합니다.
  3. 동적 정지: 고정된 TP 비율을 지원 저항치 또는 피보나치 확장치에 기반한 동적 정지로 변경한다.
  4. 기계 학습 최적화: 강도학습을 사용하여 RSI 마이너스 및 TP/SL 비율을 동적으로 조정한다.
  5. 이벤트 필터링: 경제 달력 데이터를 통합하고, 중요한 사건 전후로 자동으로 위험 매개 변수를 조정하거나 거래를 중지한다.

요약하다

이것은 구조적으로 엄격한 트렌드 추적 전략으로, 여러 기술 지표 검증을 통해 신호 신뢰성을 높이고, 과학적인 자금 관리 시스템이 하향 위험을 효과적으로 제어한다. 전략은 특히 트렌드가 명확한 시장 환경에 적합하며, 변동성이 적당한 품종에서 가장 잘 작동한다. 변수를 추가로 최적화하여 적응 메커니즘과 시장 상태 식별 모듈을 추가하면 전략의 안정성과 적응력을 크게 향상시킬 수 있다.

전략 소스 코드
// @version=5
strategy("Trend Breakout Strategy with Separated Alerts", overlay=true, initial_capital=10, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// --- Parameters ---
var float risk_per_trade = 0.02 // 2% risk per trade
var int ema_fast = 9
var int ema_slow = 21
var int rsi_length = 14
var int atr_length = 14
var float atr_multiplier_sl = 2.0 // ATR multiplier for SL
var float tp_ratio = 3.0 // TP to SL ratio = 3:1
var float trail_trigger_ratio = 0.5 // Trailing stop triggers at 50% of TP

// --- Indicators ---
ema9 = ta.ema(close, ema_fast)
ema21 = ta.ema(close, ema_slow)
rsi = ta.rsi(close, rsi_length)
atr = ta.atr(atr_length)

// --- Trend Filter ---
bull_trend = ta.crossover(ema9, ema21) or (ema9 > ema21)
bear_trend = ta.crossunder(ema9, ema21) or (ema9 < ema21)

// --- Entry Conditions ---
long_entry = bull_trend and rsi > 50 and close > high[1]
short_entry = bear_trend and rsi < 50 and close < low[1]

// --- Position Size Calculation ---
equity = strategy.equity
stop_loss_distance = atr * atr_multiplier_sl
risk_amount = equity * risk_per_trade
position_size = risk_amount / stop_loss_distance

// --- SL and TP Levels ---
long_sl = close - stop_loss_distance
long_tp = close + stop_loss_distance * tp_ratio
short_sl = close + stop_loss_distance
short_tp = close - stop_loss_distance * tp_ratio

// --- Trailing Stop (activated after 50% of TP) ---
trail_points = atr * atr_multiplier_sl * tp_ratio * trail_trigger_ratio
trail_offset = atr * atr_multiplier_sl

// --- Entries ---
if long_entry
    strategy.entry("Long", strategy.long, qty=position_size)
    strategy.exit("Long Exit", "Long", stop=long_sl, limit=long_tp, trail_points=trail_points, trail_offset=trail_offset)

if short_entry
    strategy.entry("Short", strategy.short, qty=position_size)
    strategy.exit("Short Exit", "Short", stop=short_sl, limit=short_tp, trail_points=trail_points, trail_offset=trail_offset)

// --- Alert Conditions ---
var bool long_opened = false
var bool short_opened = false

// Track position opening
long_open_alert = long_entry and not long_opened
short_open_alert = short_entry and not short_opened

// Track position closing
long_close_alert = long_opened and strategy.position_size == 0
short_close_alert = short_opened and strategy.position_size == 0

// Update position states
if long_entry
    long_opened := true
if short_entry
    short_opened := true
if strategy.position_size == 0
    long_opened := false
    short_opened := false

// --- Alerts ---
alertcondition(long_open_alert, title="Open Long", message='{"action":"buy","symbol":"{{ticker}}","price":{{close}}}')
alertcondition(long_close_alert, title="Close Long", message='{"action":"close_long","symbol":"{{ticker}}","price":{{close}}}')
alertcondition(short_open_alert, title="Open Short", message='{"action":"sell","symbol":"{{ticker}}","price":{{close}}}')
alertcondition(short_close_alert, title="Close Short", message='{"action":"close_short","symbol":"{{ticker}}","price":{{close}}}')

// --- Visualization ---
plot(ema9, color=color.blue, title="EMA9")
plot(ema21, color=color.red, title="EMA21")
plotshape(long_open_alert, title="Long Entry", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(short_open_alert, title="Short Entry", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)