RSI 반전 브레이크업 전략

저자:차오장, 날짜: 2023-11-08 12:11:03
태그:

img

전반적인 설명

이 전략은 상대 강도 지표 (RSI) 지표에 기반하고 있으며, 브레이크업 거래를 하기 위해 RSI의 과잉 구매/ 과잉 판매 원칙을 활용한다. RSI가 과잉 구매 임계 이상으로 넘어지면 긴 거리로, RSI가 과잉 판매 임계 이하로 넘어지면 짧은 거리로 이동한다. 이것은 전형적인 평균 반전 거래 전략이다.

전략 논리

  1. 사용자 입력에 기초한 RSI 지표 매개 변수를 설정합니다. RSI 기간, 과잉 매수 기준 및 과잉 판매 기준을 포함합니다.

  2. RSI가 한계치에 대한 위치에 따라 과잉 구매 또는 과잉 판매 구역에 있는지 여부를 결정합니다.

  3. RSI가 과잉 구매/ 과잉 판매 구역에서 벗어나 해당 임계선을 넘어가면 반대 방향으로 거래를 한다. 예를 들어, RSI가 과잉 구매 구역에서 과잉 구매 구역 위에 넘어가면 시장은 역전화된 것으로 간주되며, 이 시점에서 장기간 거래한다. RSI가 과잉 판매 구역에서 과잉 판매 구역 아래에 넘어가면 시장은 역전화된 것으로 간주되며, 여기서 단축된다.

  4. 진입 후 스톱 로스를 설정하고 수익 라인을 취합니다. SL / TP를 추적하고 트리거되면 포지션을 닫습니다.

  5. 이 전략은 EMA를 필터로 사용하는 옵션도 제공합니다. RSI 신호와 EMA 방향에 대한 가격 브레이크오웃이 모두 충족되면 거래 신호를 취합니다.

  6. 또한 특정 시간 프레임 내에서만 거래를 허용합니다. 포지션은 시간 프레임의 끝에서 닫을 것입니다.

이점 분석

  • 좋은 백테스트 결과를 가진 고전적인 RSI 브레이크아웃 원칙을 이용합니다.

  • 다양한 제품에 적합한 유연한 과잉 구매/ 과잉 판매 기준 설정

  • 선택적인 EMA 필터는 과도한 윙사 트레이드를 피합니다.

  • 안정성을 높이기 위해 SL/TP를 지원합니다.

  • 불합리한 기간을 피하기 위해 시간 프레임 필터를 지원합니다.

  • 양방향 가격 변동의 완전한 활용을 위해 장기 및 단위 모두 지원합니다.

위험 분석

  • RSI의 오차는 자주 발생하며, RSI에만 의존하면 부정확한 신호를 생성할 수 있습니다. 트렌드, 이동 평균 등과 결합해야합니다.

  • 부적절한 문턱 설정은 너무 자주 또는 놓친 거래로 이어집니다.

  • SL/TP의 잘못된 설정은 과도한 공격성이나 과도한 보수성을 유발합니다.

  • 잘못된 EMA 필터 설정은 유효한 트레이드를 놓칠 수도 있고 좋은 신호를 필터링할 수도 있습니다.

위험 해결 방법:

  • 다른 제품들에 대한 RSI 매개 변수를 최적화합니다.

  • 추세 지표와 결합하여 분리를 식별합니다.

  • SL/TP 매개 변수를 테스트하고 최적화합니다.

  • EMA 매개 변수를 테스트하고 최적화합니다.

최적화 방향

이 전략은 다음과 같은 측면에서 개선될 수 있습니다.

  1. RSI 매개 변수를 최적화하여 철저한 백테스트를 통해 다양한 제품에 대한 최적의 설정을 찾습니다.

  2. 더 강력한 신호를 생성하기 위해 RSI와 결합하거나 대체하는 다른 지표를 시도하십시오. 예를 들어 MACD, KD, 볼링거 밴드 등.

  3. 스톱 로스를 최적화하고 안정성을 높이기 위해 수익 전략을 취하십시오. 적응 스톱 또는 트레일링 스톱을 사용할 수 있습니다.

  4. EMA 필터 매개 변수를 최적화하거나 다른 필터를 실험하여 윙사우를 더 잘 피하십시오.

  5. 트렌드 필터 모듈을 추가하여 주요 트렌드에 대한 거래를 피합니다.

  6. 이 전략에 가장 적합한 거래 세션을 찾기 위해 다른 시간 프레임을 테스트하십시오.

요약

RSI 반전 브레이크아웃 전략은 고전적인 과소매/ 과소매 원칙에 기반한 명확한 논리를 가지고 있다. 적절한 위험 제어 필터로 극한의 평균 반전을 포착하는 것을 목표로 한다. 매개 변수 조정 및 모듈화 향상으로 안정적인 전략으로 전환할 가능성이 있다. 라이브 거래에서 최적화하고 적용하는 것이 가치가 있다.


/*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)
    



더 많은