
이 전략은 상대적으로 강한 지수 ((RSI) 지표 설계에 기초하여, RSI 지표의 오버 바이 오버 소드 원리를 이용하여 양방향의 돌파구 연산을 한다. RSI 지표 상의 설정된 오버 바이 라인을 통과할 때 더 많이 하고, RSI 지표 아래의 설정된 오버 소드 라인을 통과할 때 소수하는 것이 전형적인 역전 거래 전략이다.
사용자 입력 설정에 따라 RSI 지표의 매개 변수를 계산합니다. RSI 주기의 길이, 오버 바이 라인 마이너스, 오버 시드 라인 마이너스 등이 포함됩니다.
RSI 곡선과 비교하여 오버 바이 라인과 오버 세일 라인의 위치 관계에 따라 오버 바이 영역 또는 오버 세일 영역을 판단한다.
RSI 지표가 오버셀드 지역에서 상쇄된 값값에 대응하는 하락선과 상반되는 방향으로 상쇄된다. 예를 들어, 오버셀드 지역에서 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 상쇄된 값값이 상쇄된 값값에 대응하는 값값이 상쇄된 값
포지션 개설 후, 스톱로스 스라인을 설정한다. 스톱로스 스 상황을 추적하고, 조건이 충족될 때 포지션을 청산한다.
이 전략은 또한 EMA를 필터로 사용하는 옵션 기능을 제공합니다. RSI 지표가 더 많은 하위 신호를 수행하는 동시에 가격이 EMA를 뚫어야만 포지션을 열 수 있습니다.
전략은 또한 특정 거래 시간에만 거래하는 기능을 제공합니다. 사용자는 특정 시간 동안만 거래하고, 시간이 지나면 평지 상태에서 벗어날 수 있습니다.
위험 해소:
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
RSI 파라미터를 최적화하여 다양한 품종의 최적의 파라미터 조합을 찾습니다.
다른 지표를 대체하거나 RSI와 결합하여 더 강력한 판단 신호를 형성하십시오. 예를 들어 MACD, KD, 브린 밴드 등.
스톱 스톱 전략을 최적화하여 전략의 안정성을 높인다. 시장의 변동에 따라 이동 스톱을 설정할 수 있으며, 스톱 스톱을 추적하는 기능이 있는 전략도 있다.
EMA 필터 파라미터를 최적화하거나 다른 지표 필터를 시험하여 더 많은 을 피하십시오.
트렌드를 판단하는 모듈을 추가하고, 역으로 하락하는 것을 피하거나, 역으로 하락하는 것을 피한다.
다양한 거래 시간 변수를 테스트하여 어떤 시간대가 전략에 적합한지, 어떤 시간대가 피해야 하는지를 판단합니다.
이 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)