
이는 지수 이동 평균선(EMA) 교차와 상대 강도 지수(RSI) 확인을 기반으로 하는 추세 추종 전략입니다. 이 전략은 단기 및 장기 EMA의 교차 신호를 RSI 모멘텀 확인과 결합하고, 백분율 손절매 메커니즘을 통합하여 시장 추세의 중요한 전환점을 포착하고 위험을 통제하는 것을 목표로 합니다. 전략의 핵심은 기술 지표의 시너지 효과를 통해 거래 보안을 보장하는 동시에 거래의 정확성과 신뢰성을 높이는 것입니다.
이 전략은 이중 기술 지표 필터링 메커니즘을 사용합니다. 첫째, 단기 EMA(9기간)와 장기 EMA(21기간)의 교차를 통해 잠재적인 추세 전환점을 식별합니다. 단기 EMA가 장기 EMA를 상향 교차하고 RSI 값이 설정 레벨보다 높을 경우 시스템은 롱 신호를 생성하고, 단기 EMA가 장기 EMA를 하향 교차하고 RSI 값이 설정 레벨보다 낮을 경우 설정된 수준보다 낮으면 시스템은 짧은 신호를 생성합니다. 동시에 이 전략은 백분율 기반 손절매 메커니즘을 도입하여 각 거래에 대해 동적 손절매 가격을 설정하여 하락 위험을 효과적으로 통제합니다.
이 전략은 이동 평균 시스템과 모멘텀 지표를 결합하여 완전한 추세 추적 거래 시스템을 구축합니다. 이 전략의 주요 장점은 신뢰할 수 있는 신호 확인 메커니즘과 완벽한 위험 관리 시스템에 있습니다. 몇 가지 본질적인 한계는 있지만, 제안된 최적화 방향을 통해 전략의 전반적인 성능이 더욱 향상될 것으로 기대됩니다. 이는 중장기 추세 트레이더에게 적합한 강력한 전략 프레임워크입니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-25 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Simple Trend Following Strategy", overlay=true)
// Inputs
shortEMA = input.int(9, title="Short EMA Length", minval=1)
longEMA = input.int(21, title="Long EMA Length", minval=1)
confirmationRSI = input.int(50, title="RSI Confirmation Level", minval=1, maxval=100)
stopLossPercent = input.float(2, title="Stop Loss Percentage", minval=0.1) // Stop Loss percentage
// Calculations
emaShort = ta.ema(close, shortEMA)
emaLong = ta.ema(close, longEMA)
rsiValue = ta.rsi(close, 14)
// Buy and Sell Conditions
buySignal = ta.crossover(emaShort, emaLong) and rsiValue > confirmationRSI
sellSignal = ta.crossunder(emaShort, emaLong) and rsiValue < confirmationRSI
// Plotting Signals
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Plotting EMAs
plot(emaShort, title="Short EMA", color=color.yellow)
plot(emaLong, title="Long EMA", color=color.purple)
// Strategy logic
strategy.entry("Buy", strategy.long, when=buySignal)
strategy.entry("Sell", strategy.short, when=sellSignal)
// Calculate stop loss price based on stopLossPercent
longStopLossPrice = strategy.position_avg_price * (1 - stopLossPercent / 100)
shortStopLossPrice = strategy.position_avg_price * (1 + stopLossPercent / 100)
// Draw stop loss line for long positions
if (strategy.position_size > 0) // For long positions
line.new(x1=bar_index, y1=longStopLossPrice, x2=bar_index + 1, y2=longStopLossPrice, color=color.red, width=2, style=line.style_dashed)
// Draw stop loss line for short positions
if (strategy.position_size < 0) // For short positions
line.new(x1=bar_index, y1=shortStopLossPrice, x2=bar_index + 1, y2=shortStopLossPrice, color=color.green, width=2, style=line.style_dashed)