
이 전략은 이동 평균선, RSI 지표, 추적 손절매를 기반으로 하는 양적 거래 시스템입니다. 기술 분석에서 추세 추적과 모멘텀 지표를 결합하여 엄격한 진입 및 청산 조건을 설정함으로써 위험 관리형 거래를 달성합니다. 이 전략의 핵심 논리는 상승 추세에서 시장에 진입할 과매도 기회를 찾고, 추적 손절매를 사용하여 수익을 보호하는 것입니다.
이 전략은 200일 간단 이동 평균(SMA)을 추세 판단의 기준으로 사용하고 이를 상대 강도 지수(RSI)와 결합하여 거래 신호를 생성합니다. 구체적으로:
이는 완전한 구조와 명확한 논리를 갖춘 양적 거래 전략입니다. 안정적인 수익을 추구하면서 리스크도 통제하기 위해 여러 가지 기술 지표를 결합합니다. 최적화의 여지가 있기는 하지만 기본 프레임워크는 실용성과 확장성이 좋습니다. 이 전략은 중장기 투자자에게 적합하며 다양한 시장 환경에 잘 적응합니다.
/*backtest
start: 2025-01-09 00:00:00
end: 2025-01-16 00:00:00
period: 15m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=5
strategy("200 SMA Crossover Strategy", overlay=false)
// Define inputs
smaLength = input.int(200, title="SMA Length")
rsiLength = input.int(14, title="RSI Length")
rsiThreshold = input.float(40, title="RSI Threshold")
trailStopPercent = input.float(5.0, title="Trailing Stop Loss (%)")
waitingPeriod = input.int(10, title="Waiting Period (Days)")
// Calculate 200 SMA
sma200 = ta.sma(close, smaLength)
// Calculate RSI
rsi = ta.rsi(close, rsiLength)
// Plot the 200 SMA and RSI
plot(sma200, color=color.blue, linewidth=2, title="200 SMA")
plot(rsi, color=color.purple, title="RSI", display=display.none)
// Define buy and sell conditions
var isLong = false
var float lastExitTime = na
var float trailStopPrice = na
// Explicitly declare timeSinceExit as float
float timeSinceExit = na(lastExitTime) ? na : (time - lastExitTime) / (24 * 60 * 60 * 1000)
canEnter = na(lastExitTime) or timeSinceExit > waitingPeriod
buyCondition = close > sma200 and rsi < rsiThreshold and canEnter
if (buyCondition and not isLong)
strategy.entry("Buy", strategy.long)
trailStopPrice := na
isLong := true
// Update trailing stop loss if long
if (isLong)
trailStopPrice := na(trailStopPrice) ? close * (1 - trailStopPercent / 100) : math.max(trailStopPrice, close * (1 - trailStopPercent / 100))
// Check for trailing stop loss or sell condition
if (isLong and (close < trailStopPrice or close < sma200))
strategy.close("Buy")
lastExitTime := time
isLong := false
// Plot buy and sell signals
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=(isLong and close < trailStopPrice) or close < sma200, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")