
이 전략은 상대 강도 지수(RSI)를 기반으로 한 다중 레벨 지표 오버레이 거래 시스템입니다. 이 전략은 특정한 거래 시간 창 내에서 작동하고, RSI 지표의 매수 과다 및 매도 과다 신호를 통해 거래 기회를 파악하고, 이를 동적 포지션 조정 메커니즘과 결합하여 시장이 반대 방향으로 움직일 때 일괄적으로 포지션을 구축하여 전체 수익을 최적화합니다. 이 전략은 손절매 관리를 위한 평균 진입 가격을 기반으로 하는 목표 이익 방법을 사용합니다.
이 전략은 주로 다음과 같은 핵심 구성 요소를 기반으로 합니다.
이 전략은 RSI 지표와 일괄 거래 개시 메커니즘을 결합하여 비교적 완전한 거래 시스템을 형성합니다. 이 전략의 핵심적인 장점은 다단계 신호 필터링 메커니즘과 유연한 포지션 관리 방식에 있지만, 동시에 추세 시장 리스크와 매개변수 최적화와 같은 문제에도 주의를 기울여야 합니다. 트렌드 필터를 추가하고, 손절매 메커니즘을 최적화하고, 다른 개선 사항을 적용하면 전략의 전반적인 성과를 더욱 개선할 수 있습니다.
/*backtest
start: 2024-12-10 00:00:00
end: 2025-01-08 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=6
strategy("TonyM RSI", overlay=true)
// Input Settings
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
startHour = input.int(2, "Start Hour", minval=0, maxval=23, group="Trading Window")
endHour = input.int(4, "End Hour", minval=0, maxval=23, group="Trading Window")
// RSI Calculation
change = ta.change(rsiSourceInput)
up = ta.rma(math.max(change, 0), rsiLengthInput)
down = ta.rma(-math.min(change, 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
// Time Filter
inTradingWindow = (hour >= startHour and hour < endHour)
// Strategy Settings
buyLevel = 30
sellLevel = 70
scaleDistance = 1.0 // Distance in points to add to the position
takeProfitPoints = 1.5 // Profit target from average price
initialQty = 1 // Initial trade size
scalingQty = 1 // Additional trade size for scaling
// Trade Logic
if inTradingWindow
// Entry Logic
if rsi <= buyLevel and strategy.position_size == 0
strategy.entry("Buy", strategy.long, qty=initialQty)
if rsi >= sellLevel and strategy.position_size == 0
strategy.entry("Sell", strategy.short, qty=initialQty)
// Scaling Logic
if strategy.position_size > 0 and close <= strategy.position_avg_price - scaleDistance
strategy.entry("Scale Buy", strategy.long, qty=scalingQty)
if strategy.position_size < 0 and close >= strategy.position_avg_price + scaleDistance
strategy.entry("Scale Sell", strategy.short, qty=scalingQty)
// Exit Logic (based on average price)
if strategy.position_size > 0
strategy.exit("Take Profit Long", "Buy", limit=strategy.position_avg_price + takeProfitPoints)
if strategy.position_size < 0
strategy.exit("Take Profit Short", "Sell", limit=strategy.position_avg_price - takeProfitPoints)
// Plot RSI
plot(rsi, "RSI", color=color.blue, linewidth=1)
rsiUpperBand = hline(70, "RSI Upper Band", color=color.red)
rsiLowerBand = hline(30, "RSI Lower Band", color=color.green)
fill(rsiUpperBand, rsiLowerBand, color=color.new(color.gray, 90))