RSI 동적 손절매 지능형 거래 전략

RSI SMA ATR
생성 날짜: 2024-11-12 11:39:06 마지막으로 수정됨: 2024-11-12 11:39:06
복사: 2 클릭수: 503
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

RSI 동적 손절매 지능형 거래 전략

개요

이 전략은 RSI 지표에 기반한 동적 스톱로스 거래 시스템으로, SMA 평균선과 ATR 파도 지표를 결합하여 거래 결정을 최적화한다. 이 전략은 다단계 스톱로스 계획을 채택하여, 피라미드형 평점 방식으로 수익을 극대화하고, 동시에 ATR 동적 스톱로스를 사용하여 위험을 제어한다. 이 전략은 고도의 자율성을 가지고 있으며, 시장의 변동에 따라 거래 매개 변수를 자동으로 조정할 수 있다.

전략 원칙

이 전략은 주로 RSI 오버소드 범위에 의존한다. RSI<30은 포지션 개시 신호이며, 가격이 200일 평균선 위에 있어야 상승 추세를 보장한다. 시스템은 삼중 정지 목표를 채택한다.

  1. 입시 조건: RSI 30 이하와 SMA 200 이상의 가격
  2. 포지션 관리: 한번의 포지션에 75%의 자금을 사용한다.
  3. 스톱로스 설정: 1.5배 ATR 값에 기반한 동적 스톱로스
  4. 정지 전략: 각각 5%, 10%, 15%의 위치에 3개의 정지점을 설정하고, 33%, 66%, 100%의 비율로 순차적으로 청산

전략적 이점

  1. 동적 위험 관리: ATR을 통해 시장 변동에 적응
  2. 을 분배하는 것: 감정적 방해를 줄이고 수익률을 높이는 방법
  3. 트렌드 확인: 위조 신호를 균열 필터링
  4. 자금 관리: 백분율 포지션 통제를 사용하여 다양한 계정 크기에 적합합니다.
  5. 수수료 최적화: 거래비용을 고려하여 실제 거래에 가깝다

전략적 위험

  1. 평균선 지연으로 인해 진입이 지연될 수 있다.
  2. RSI 과매매는 반드시 반전을 의미하지 않습니다.
  3. 대량 입장은 더 큰 철회로 이어질 수 있습니다.
  4. 을 자주 분할하는 것은 거래 비용을 증가시킬 수 있습니다. 이러한 위험은 파라미터를 조정하고 필터링 조건을 추가하여 관리하는 것이 좋습니다.

전략 최적화 방향

  1. 볼륨 증가 확인 신호
  2. 추세 강도 지표 소개
  3. 정지 비율 분배를 최적화
  4. 시간 주기 필터를 추가합니다.
  5. 변동율에 적응하는 포지션 관리를 고려하십시오.

요약하다

이 전략은 기술 지표와 동적 리스크 관리를 결합하여 비교적 완전한 거래 시스템을 구축한다. 이 전략의 장점은 자율성이 강하고, 위험도 조절 가능하지만, 실제 시장 상황에 따라 변수를 최적화해야 한다는 것이다. 이 전략은 중장기 투자자에게 적합하며, 체계화된 거래의 좋은 출발점이 된다.

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

// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA/4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © wielkieef

//@version=5
strategy("Simple RSI stock Strategy [1D] ", overlay=true, pyramiding=1, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=75, calc_on_order_fills=false, slippage=0, commission_type=strategy.commission.percent, commission_value=0.03)

// Rsi
oversoldLevel = input(30, title="Oversold Level")
overboughtLevel = input(70, title="Overbought Level")
rsi = ta.rsi(close, 5)
rsi_overbought = rsi > overboughtLevel  
rsi_oversold = rsi < oversoldLevel

// Sma 200
lenghtSMA = input(200, title = "SMA lenght")
sma200 = ta.sma(close, lenghtSMA)

// ATR stop-loss
atrLength = input.int(20, title="ATR Length")
atrMultiplier = input.float(1.5, title="ATR Multiplier")
atrValue = ta.atr(atrLength)
var float long_stop_level = na
var float short_stop_level = na
var float tp1_level = na
var float tp2_level = na
var float tp3_level = na

// Strategy entry
long = (rsi_oversold ) and close > sma200 

// Take Profit levels
tp_1 = input.float(5.0, "TP 1", minval=0.1, step=0.1)
tp_2 = input.float(10.0, "TP 2", minval=0.2, step=0.1)
tp_3 = input.float(15.0, "TP 3", minval=0.3, step=0.1)

if long
    strategy.entry('Long', strategy.long)
    long_stop_level := close - atrMultiplier * atrValue
    tp1_level := strategy.position_avg_price * (1 + tp_1 / 100)
    tp2_level := strategy.position_avg_price * (1 + tp_2 / 100)
    tp3_level := strategy.position_avg_price * (1 + tp_3 / 100)

// basic SL - this code is from author RafaelZioni, modified by wielkieef
sl = input.float(25.0, 'Basic Stop Loss %', step=0.1)
per(procent) =>
    strategy.position_size != 0 ? math.round(procent / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)

// ATR SL
if (strategy.position_size > 0 and (close <= long_stop_level))
    strategy.close("Long")
    tp1_level := na
    tp2_level := na
    tp3_level := na
plot(long_stop_level, color=color.orange, linewidth=2, title="Long Stop Loss")

// TP levels
if (strategy.position_size > 0)
    if (not na(tp1_level) and close >= tp1_level)
        tp1_level := na
    if (not na(tp2_level) and close >= tp2_level)
        tp2_level := na
    if (not na(tp3_level) and close >= tp3_level)
        tp3_level := na

plot(strategy.position_size > 0 and not na(tp1_level) ? tp1_level : na, color=color.gray, style=plot.style_circles , linewidth=1, title="Take Profit 1")
plot(strategy.position_size > 0 and not na(tp2_level) ? tp2_level : na, color=color.gray, style=plot.style_circles , linewidth=1, title="Take Profit 2")
plot(strategy.position_size > 0 and not na(tp3_level) ? tp3_level : na, color=color.gray, style=plot.style_circles , linewidth=1, title="Take Profit 3")

// Strategy exit points for Take Profits
strategy.exit('TP 1', from_entry="Long", qty_percent=33, profit=per(tp_1), loss=per(sl))
strategy.exit('TP 2', from_entry="Long", qty_percent=66, profit=per(tp_2), loss=per(sl))
strategy.exit('TP 3', from_entry="Long", qty_percent=100, profit=per(tp_3), loss=per(sl))

// by wielkieef