
이 전략은 RSI 지표를 계산하고 오버로 오버로 범위를 설정하여 동적인 스톱로스와 목표 수익을 복귀시켜 거래 전략을 구축합니다. RSI 지표 상의 오버로스를 통과 할 때 공백을 만들고 오버로스를 통과 할 때 더 많이 만들며, 트래킹 스톱로스와 목표 수익을 설정하여 포지션을 종료합니다.
이 전략은 14일 RSI 지표를 사용하여 시장의 기술적 형태를 판단한다. RSI 지표는 시장이 과매매되거나 과매매되는지를 판단하기 위해 일정 기간 동안의 상승과 하락의 동력의 비율을 반영한다. 이 전략의 RSI 길이는 14이다.
또한, 이 전략은 동적 추적 손실 메커니즘을 사용합니다. 다중 상위 포지션을 보유 할 때, 폐쇄 가격의 97%를 위해 중지 손실을 추적합니다. 빈 상위 포지션을 보유 할 때, 폐쇄 가격의 103%를 위해 중지 손실을 추적합니다.
마지막으로, 이 전략은 또한 목표 수익 메커니즘을 사용합니다. 지분 수익률이 20%에 도달하면 포지션에서 탈퇴합니다. 이것은 수익의 일부를 잠금하여 수익의 회귀를 방지 할 수 있습니다.
이 전략에는 다음과 같은 장점이 있습니다.
이 전략에는 몇 가지 위험도 있습니다.
위와 같은 위험은 RSI 파라미터를 최적화하고, 스톱 스피드를 조정하고, 목표 수익 요구 사항을 적절하게 완화하여 해결할 수 있습니다.
이 전략은 다음과 같은 방향으로 최적화될 수 있습니다.
이 전략의 전체적인 생각은 명확하고, RSI 지표를 사용하여 과매매를 판단하고, 동적 스톱로스와 목표 수익 철수를 지원한다. 이점은 구현을 이해하기 쉽고, 위험을 통제하고, 확장성이 강하다. 다음 단계는 신호 품질, 동적 조정 파라미터 등을 향상시키는 방향으로 최적화 할 수 있으며, 전략을 더 지능화한다.
/*backtest
start: 2024-01-04 00:00:00
end: 2024-02-03 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Modified RSI-Based Trading Strategy", overlay=true)
// RSI settings
rsiLength = input(14, title="RSI Length")
overboughtLevel = 70
oversoldLevel = 30
// User-defined parameters
trailingStopPercentage = input(3, title="Trailing Stop Percentage (%)")
profitTargetPercentage = input(20, title="Profit Target Percentage (%)")
rsiValue = ta.rsi(close, rsiLength)
var float trailingStopLevel = na
var float profitTargetLevel = na
// Entry criteria
enterLong = ta.crossover(rsiValue, oversoldLevel)
enterShort = ta.crossunder(rsiValue, overboughtLevel)
// Exit criteria
exitLong = ta.crossover(rsiValue, overboughtLevel)
exitShort = ta.crossunder(rsiValue, oversoldLevel)
// Trailing stop calculation
if (strategy.position_size > 0)
trailingStopLevel := close * (1 - trailingStopPercentage / 100)
if (strategy.position_size < 0)
trailingStopLevel := close * (1 + trailingStopPercentage / 100)
// Execute the strategy
if (enterLong)
strategy.entry("Buy", strategy.long)
if (exitLong or ta.crossover(close, trailingStopLevel) or ta.change(close) > profitTargetPercentage / 100)
strategy.close("Buy")
if (enterShort)
strategy.entry("Sell", strategy.short)
if (exitShort or ta.crossunder(close, trailingStopLevel) or ta.change(close) < -profitTargetPercentage / 100)
strategy.close("Sell")
// Plot RSI and overbought/oversold levels
plot(rsiValue, title="RSI", color=color.blue)
hline(overboughtLevel, "Overbought", color=color.red, linestyle=hline.style_dashed)
hline(oversoldLevel, "Oversold", color=color.green, linestyle=hline.style_dashed)