RSI 양방향 돌파 전략


생성 날짜: 2023-11-08 12:11:03 마지막으로 수정됨: 2023-11-08 12:11:03
복사: 0 클릭수: 669
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

RSI 양방향 돌파 전략

개요

이 전략은 상대적으로 강한 지수 ((RSI) 지표 설계에 기초하여, RSI 지표의 오버 바이 오버 소드 원리를 이용하여 양방향의 돌파구 연산을 한다. RSI 지표 상의 설정된 오버 바이 라인을 통과할 때 더 많이 하고, RSI 지표 아래의 설정된 오버 소드 라인을 통과할 때 소수하는 것이 전형적인 역전 거래 전략이다.

전략 원칙

  1. 사용자 입력 설정에 따라 RSI 지표의 매개 변수를 계산합니다. RSI 주기의 길이, 오버 바이 라인 마이너스, 오버 시드 라인 마이너스 등이 포함됩니다.

  2. RSI 곡선과 비교하여 오버 바이 라인과 오버 세일 라인의 위치 관계에 따라 오버 바이 영역 또는 오버 세일 영역을 판단한다.

  3. RSI 지표가 오버셀드 지역에서 상쇄된 값값에 대응하는 하락선과 상반되는 방향으로 상쇄된다. 예를 들어, 오버셀드 지역에서 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 값값이 상쇄된 값

  4. 포지션 개설 후, 스톱로스 스라인을 설정한다. 스톱로스 스 상황을 추적하고, 조건이 충족될 때 포지션을 청산한다.

  5. 이 전략은 또한 EMA를 필터로 사용하는 옵션 기능을 제공합니다. RSI 지표가 더 많은 하위 신호를 수행하는 동시에 가격이 EMA를 뚫어야만 포지션을 열 수 있습니다.

  6. 전략은 또한 특정 거래 시간에만 거래하는 기능을 제공합니다. 사용자는 특정 시간 동안만 거래하고, 시간이 지나면 평지 상태에서 벗어날 수 있습니다.

우위 분석

  • RSI의 고전적 돌파법칙을 이용해서 재검토하는 것이 더 효과적이다.
  • 다양한 품종에 맞게 과매매한 값을 조정할 수 있습니다.
  • 작은 범위의 진동으로 인해 빈번하게 평점을 취하는 것을 피하기 위해 EMA 필터 신호를 사용 할 수 있습니다.
  • 스피드 스피드 기능을 지원하여 전략의 안정성을 향상시킬 수 있습니다.
  • 특정 거래 시간을 설정하여 부적절한 시간대에 거래하는 것을 피하는 것을 지원합니다.
  • 더 많은 포커스 거래가 가능하도록 지원하고, 시장의 양방향 변동성을 최대한 활용할 수 있다.

위험 분석

  • RSI 지표는 이탈하기 쉽다. RSI 지표 판단만으로 거래 신호가 정확하지 않을 수 있다. 추세, 평균 등과 결합한 판단이 필요하다.
  • 오버 바이 오버 셀 값을 잘못 설정하면 너무 자주 거래하거나 거래 기회를 놓치게 될 수 있습니다.
  • 부적절하게 설정된 스톱더는 너무 급진적이거나 보수적인 전략을 만들 수 있다.
  • EMA 필터 설정이 잘못되면 거래 기회를 놓치거나 유효한 신호를 필터링 할 수 있습니다.

위험 해소:

  • RSI 파라미터를 최적화하여 다른 품종에 적합한 파라미터를 조정한다.
  • 트렌드 지표와 같은 판단이 상황을 벗어날 수 있고, 잘못된 신호를 피할 수 있다.
  • 테스트 및 최적화 스탠드 패러미터를 사용하여 최적의 패러미터를 찾습니다.
  • 테스트 및 최적화 EMA 매개 변수, 최적의 필터링 수준을 찾아

전략 최적화 방향

이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.

  1. RSI 파라미터를 최적화하여 다양한 품종의 최적의 파라미터 조합을 찾습니다.

  2. 다른 지표를 대체하거나 RSI와 결합하여 더 강력한 판단 신호를 형성하십시오. 예를 들어 MACD, KD, 브린 밴드 등.

  3. 스톱 스톱 전략을 최적화하여 전략의 안정성을 높인다. 시장의 변동에 따라 이동 스톱을 설정할 수 있으며, 스톱 스톱을 추적하는 기능이 있는 전략도 있다.

  4. EMA 필터 파라미터를 최적화하거나 다른 지표 필터를 시험하여 더 많은 을 피하십시오.

  5. 트렌드를 판단하는 모듈을 추가하고, 역으로 하락하는 것을 피하거나, 역으로 하락하는 것을 피한다.

  6. 다양한 거래 시간 변수를 테스트하여 어떤 시간대가 전략에 적합한지, 어떤 시간대가 피해야 하는지를 판단합니다.

요약하다

이 RSI 쌍방향 돌파 전략은 전체적인 아이디어가 명확하며, 클래식 RSI 오버 바이 오버 셀 원칙을 사용하여 반전 거래를 한다. 오버 바이 오버 셀 영역의 반전 기회를 잡을 수 있고, EMA 필터링과 스로스 스톱을 통해 위험을 제어 할 수 있다. 매개 변수 최적화 및 모듈 최적화 공간을 통해 더 안정적이고 신뢰할 수있는 반전 전략을 만들 수 있다.

전략 소스 코드
/*backtest
start: 2023-10-08 00:00:00
end: 2023-11-07 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © REV0LUTI0N

//@version=4

strategy("RSI Strategy", overlay=true, initial_capital = 10000, default_qty_value = 10000, default_qty_type = strategy.cash)

// Strategy Backtesting
startDate  = input(timestamp("2021-10-01T00:00:00"), type = input.time, title='Backtesting Start Date')
finishDate = input(timestamp("9999-12-31T00:00:00"), type = input.time, title='Backtesting End Date')

time_cond  = true
// Strategy

Length = input(12, minval=1)
src = input(close, title="Source")
overbought = input(70, minval=1)
oversold = input(30, minval=1)
xRSI = rsi(src, Length)
    
rsinormal = input(true, title="Overbought Go Long & Oversold Go Short")
rsiflipped = input(false, title="Overbought Go Short & Oversold Go Long")

// EMA Filter
noemafilter = input(true, title="No EMA Filter")
useemafilter = input(false, title="Use EMA Filter")
ema_length = input(defval=15, minval=1, title="EMA Length")
emasrc = input(close, title="Source")
ema = ema(emasrc, ema_length)
plot(ema, "EMA", style=plot.style_linebr, color=#cad850, linewidth=2)

//Time Restriction Settings
startendtime = input("", title='Time Frame To Enter Trades')
enableclose = input(false, title='Enable Close Trade At End Of Time Frame')
timetobuy = (time(timeframe.period, startendtime))
timetoclose = na(time(timeframe.period, startendtime))

// Stop Loss & Take Profit % Based
enablesl = input(false, title='Enable Stop Loss')
enabletp = input(false, title='Enable Take Profit')
stopTick = input(5.0, title='Stop Loss %', type=input.float, step=0.1) / 100
takeTick = input(10.0, title='Take Profit %', type=input.float, step=0.1) / 100

longStop = strategy.position_avg_price * (1 - stopTick)
shortStop = strategy.position_avg_price * (1 + stopTick)
shortTake = strategy.position_avg_price * (1 - takeTick)
longTake = strategy.position_avg_price * (1 + takeTick)

plot(strategy.position_size > 0 and enablesl ? longStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Long Fixed SL")
plot(strategy.position_size < 0 and enablesl ? shortStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Short Fixed SL")
plot(strategy.position_size > 0 and enabletp ? longTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Long Take Profit")
plot(strategy.position_size < 0 and enabletp ? shortTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Short Take Profit")

// Alert messages
message_enterlong  = input("", title="Long Entry message")
message_entershort = input("", title="Short Entry message")
message_closelong = input("", title="Close Long message")
message_closeshort = input("", title="Close Short message")

// Strategy Execution
if (xRSI > overbought and close > ema and time_cond and timetobuy and rsinormal and useemafilter)
    strategy.entry("Long", strategy.long, alert_message = message_enterlong)
    
if (xRSI < oversold and close < ema and time_cond and timetobuy and rsinormal and useemafilter)
    strategy.entry("Short", strategy.short, alert_message = message_entershort)
    
if (xRSI < oversold and close > ema and time_cond and timetobuy and rsiflipped and useemafilter)
    strategy.entry("Long", strategy.long, alert_message = message_enterlong)
    
if (xRSI > overbought and close < ema and time_cond and timetobuy and rsiflipped and useemafilter)
    strategy.entry("Short", strategy.short, alert_message = message_entershort)
    
if (xRSI > overbought and time_cond and timetobuy and rsinormal and noemafilter)
    strategy.entry("Long", strategy.long, alert_message = message_enterlong)
    
if (xRSI < oversold and time_cond and timetobuy and rsinormal and noemafilter)
    strategy.entry("Short", strategy.short, alert_message = message_entershort)
    
if (xRSI < oversold and time_cond and timetobuy and rsiflipped and noemafilter)
    strategy.entry("Long", strategy.long, alert_message = message_enterlong)
    
if (xRSI > overbought and time_cond and timetobuy and rsiflipped and noemafilter)
    strategy.entry("Short", strategy.short, alert_message = message_entershort)
    
if strategy.position_size > 0 and timetoclose and enableclose
    strategy.close_all(alert_message = message_closelong)
if strategy.position_size < 0 and timetoclose and enableclose
    strategy.close_all(alert_message = message_closeshort)
    
if strategy.position_size > 0 and enablesl and time_cond
    strategy.exit(id="Close Long", stop=longStop, limit=longTake, alert_message = message_closelong)
if strategy.position_size < 0 and enablesl and time_cond
    strategy.exit(id="Close Short", stop=shortStop, limit=shortTake, alert_message = message_closeshort)
    
if strategy.position_size > 0 and enabletp and time_cond
    strategy.exit(id="Close Long", stop=longStop, limit=longTake, alert_message = message_closelong)
if strategy.position_size < 0 and enabletp and time_cond
    strategy.exit(id="Close Short", stop=shortStop, limit=shortTake, alert_message = message_closeshort)