
이 전략은 간단한 이동 평균 (SMA) 과 상대적으로 약한 지표 (RSI) 를 결합한 트렌드 추적 거래 시스템입니다. 그것은 단기 및 장기 이동 평균의 교차로로 트렌드 방향을 식별하고 RSI를 사용하여 운동량을 확인하여 시장에서 높은 확률의 거래 기회를 찾습니다. 이 전략은 또한 거래의 위험을 효과적으로 제어 할 수있는 완전한 위험 관리 모듈을 포함합니다.
전략의 핵심 논리는 두 가지 기술 지표를 결합해서 사용하는 데 기초합니다.
이것은 구조적이고, 논리적으로 명확한 트렌드 추적 전략이다. SMA와 RSI를 결합하여 트렌드를 포착하고 과도한 거래 지역에서 거래하는 것을 피할 수 있다. 내장 된 위험 관리 메커니즘은 전략의 안정성을 보장한다. 일부 고유 한 한계가 있지만, 제안 된 최적화 방향은 전략의 성능을 더욱 향상시킬 수 있다.
/*backtest
start: 2025-02-16 00:00:00
end: 2025-02-23 00:00:00
period: 6m
basePeriod: 6m
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=6
strategy("WEN - SMA with RSI Strategy", overlay=true)
// Define input parameters
// SMA Inputs
shortLength = input(8, title="Short MA Length")
longLength = input(21, title="Long MA Length")
// RSI Inputs
rsiLength = input(14, title="RSI Length")
rsiOverbought = input(70, title="RSI Overbought")
rsiOversold = input(30, title="RSI Oversold")
// Calculate indicators
// Moving Averages
shortMA = ta.sma(close, shortLength)
longMA = ta.sma(close, longLength)
// RSI
rsi = ta.rsi(close, rsiLength)
// Plot indicators
plot(shortMA, title="Short MA", color=color.blue)
plot(longMA, title="Long MA", color=color.red)
// RSI is typically plotted in a separate panel in trading platforms
// Entry conditions with RSI confirmation
smaLongCondition = ta.crossover(shortMA, longMA)
smaShortCondition = ta.crossunder(shortMA, longMA)
rsiLongCondition = rsi < rsiOverbought // Not overbought for long entry
rsiShortCondition = rsi > rsiOversold // Not oversold for short entry
// Combined entry conditions
longCondition = smaLongCondition and rsiLongCondition
shortCondition = smaShortCondition and rsiShortCondition
// Execute trades
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.close("Long")
strategy.entry("Short", strategy.short)
// Set stop loss and take profit
stopLoss = input(1, title="Stop Loss (%)") / 100
takeProfit = input(2, title="Take Profit (%)") / 100
longStopLossPrice = strategy.position_avg_price * (1 - stopLoss)
longTakeProfitPrice = strategy.position_avg_price * (1 + takeProfit)
shortStopLossPrice = strategy.position_avg_price * (1 + stopLoss)
shortTakeProfitPrice = strategy.position_avg_price * (1 - takeProfit)
strategy.exit("Take Profit / Stop Loss", from_entry="Long", stop=longStopLossPrice, limit=longTakeProfitPrice)
strategy.exit("Take Profit / Stop Loss", from_entry="Short", stop=shortStopLossPrice, limit=shortTakeProfitPrice)