
이 전략은 단기 및 장기 이동 평균의 교차를 통해 시장의 경향 방향을 결정하고 동력 필터로 RSI를 사용하여 트렌드의 강도를 확인하여 거래 신호의 신뢰성을 향상시킵니다. 이 전략은 또한 위험 관리를 위해 백분율의 중지 및 중지도 포함합니다.
이 전략은 9주기 및 21주기의 간단한 이동 평균 (SMA) 을 주요 트렌드 지표로 사용합니다. 단기 평균이 장기 평균을 상향으로 가로질러 RSI가 50보다 크면, 시스템은 멀티 신호를 발생시킵니다. 단기 평균이 장기 평균을 상향으로 가로질러 RSI가 50보다 작으면, 시스템은 마이너스 신호를 발생시킵니다. 이 디자인은 거래 방향과 시장의 추세와 동력에 일치하도록 보장합니다.
이것은 구조적이고, 논리적으로 명확한 트렌드 추적 전략이다. 평행선 교차를 통해 기본 트렌드 방향을 제공하고, RSI는 동력을 확인하고, 위험 관리 장치와 함께 전체 거래 시스템을 형성한다. 일부 고유 한 한계가 있지만, 지속적인 최적화 및 조정으로 이 전략은 다양한 시장 환경에서 안정적인 성능을 유지할 것으로 예상된다. 전략의 성공은 파라미터 최적화 및 위험 제어의 실행에 달려있다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Moving Average Crossover + RSI Strategy", overlay=true, shorttitle="MA RSI Strategy")
// --- Input Parameters ---
shortMA = input.int(9, title="Short MA Period", minval=1)
longMA = input.int(21, title="Long MA Period", minval=1)
rsiLength = input.int(14, title="RSI Length", minval=1)
rsiOverbought = input.int(70, title="RSI Overbought Level", minval=50, maxval=100)
rsiOversold = input.int(30, title="RSI Oversold Level", minval=0, maxval=50)
stopLossPercent = input.float(1, title="Stop Loss Percentage", minval=0.1, maxval=10.0) / 100
takeProfitPercent = input.float(2, title="Take Profit Percentage", minval=0.1, maxval=10.0) / 100
// --- Calculate Moving Averages ---
shortMA_value = ta.sma(close, shortMA)
longMA_value = ta.sma(close, longMA)
// --- Calculate RSI ---
rsi_value = ta.rsi(close, rsiLength)
// --- Buy and Sell Conditions ---
longCondition = ta.crossover(shortMA_value, longMA_value) and rsi_value > 50
shortCondition = ta.crossunder(shortMA_value, longMA_value) and rsi_value < 50
// --- Plot Moving Averages ---
plot(shortMA_value, color=color.blue, linewidth=2, title="Short MA")
plot(longMA_value, color=color.red, linewidth=2, title="Long MA")
// --- Plot RSI (Optional) ---
hline(rsiOverbought, "Overbought", color=color.red)
hline(rsiOversold, "Oversold", color=color.green)
plot(rsi_value, color=color.purple, title="RSI")
// --- Strategy Execution ---
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
// --- Risk Management (Stop Loss and Take Profit) ---
longStopLoss = close * (1 - stopLossPercent)
longTakeProfit = close * (1 + takeProfitPercent)
shortStopLoss = close * (1 + stopLossPercent)
shortTakeProfit = close * (1 - takeProfitPercent)
// Set the stop loss and take profit for long and short positions
strategy.exit("Long Exit", from_entry="Long", stop=longStopLoss, limit=longTakeProfit)
strategy.exit("Short Exit", from_entry="Short", stop=shortStopLoss, limit=shortTakeProfit)