
이 전략은 다중 기술 지표에 기반한 트렌드 추적 거래 시스템으로, 이동 평균 (EMA), 이동 평균 수축 지표 (MACD) 및 상대적으로 강한 지표 (RSI) 의 세 가지 클래식 기술 지표를 결합하여 시장 추세 변화와 동력을 포착하여 거래합니다. 전략은 빠른 EMA (9 주기) 및 느린 EMA (21 주기), MACD (12 주기, 26 주기) 및 RSI (14 주기) 와 같은 파라미터 설정을 사용하여 지표가 교차하고 경계를 돌파 할 때 거래 신호를 냅니다.
이 전략의 핵심 논리는 여러 기술 지표의 연동 확인을 통해 시장 추세의 전환점을 식별하는 것이다. 구체적으로 다음과 같은 세 가지 측면의 신호 확인을 포함한다:
이 전략은 여러 기술 지표의 교차 검증을 통해 시장 추세 변화를 포착하고, 더 나은 신뢰성과 적응력을 가지고 있다. 그러나 실제 응용에서는 여전히 신호 지연 및 과도한 거래와 같은 문제를 주의해야하며, 적응 파라미터, 스톱저스 메커니즘 및 시장 환경 인식 등의 방법을 도입하여 전략의 안정성과 수익성을 높이기 위해 최적화를 권장한다. 사용 과정에서 충분한 역사적 데이터 재검토와 파라미터 최적화를 수행하고, 실제 거래 효과에 따라 지속적으로 조정 및 개선하는 것이 좋습니다.
/*backtest
start: 2024-02-20 00:00:00
end: 2025-02-17 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA + MACD + RSI Strategy with Long and Short", overlay=true)
// Input parameters for MACD, EMA, and RSI
fast_ema_length = input.int(9, title="Fast EMA Length", minval=1)
slow_ema_length = input.int(21, title="Slow EMA Length", minval=1)
macd_short_length = input.int(12, title="MACD Short Length", minval=1)
macd_long_length = input.int(26, title="MACD Long Length", minval=1)
macd_signal_length = input.int(9, title="MACD Signal Length", minval=1)
rsi_length = input.int(14, title="RSI Length", minval=1)
rsi_oversold_level = input.int(30, title="RSI Oversold Level", minval=1)
rsi_overbought_level = input.int(70, title="RSI Overbought Level", minval=1)
// Calculate the MACD line and Signal line
[macdLine, signalLine, _] = ta.macd(close, macd_short_length, macd_long_length, macd_signal_length)
// Calculate the EMAs
fast_ema = ta.ema(close, fast_ema_length)
slow_ema = ta.ema(close, slow_ema_length)
// Calculate the RSI
rsi = ta.rsi(close, rsi_length)
// Conditions for long entry (bullish)
macd_bullish_crossover = ta.crossover(macdLine, signalLine) // MACD line crosses above Signal line
ema_bullish_crossover = ta.crossover(fast_ema, slow_ema) // Fast EMA crosses above Slow EMA
rsi_above_30 = rsi > rsi_oversold_level // RSI above 30 (not oversold)
long_condition = macd_bullish_crossover and ema_bullish_crossover and rsi_above_30
// Conditions for short entry (bearish)
macd_bearish_crossover = ta.crossunder(macdLine, signalLine) // MACD line crosses below Signal line
ema_bearish_crossover = ta.crossunder(fast_ema, slow_ema) // Fast EMA crosses below Slow EMA
rsi_below_70 = rsi < rsi_overbought_level // RSI below 70 (not overbought)
short_condition = macd_bearish_crossover and ema_bearish_crossover and rsi_below_70
// Execute long trade
if (long_condition)
strategy.entry("Long", strategy.long)
// Execute short trade
if (short_condition)
strategy.entry("Short", strategy.short)
// Plot the EMAs and MACD for visualization
plot(fast_ema, color=color.green, linewidth=2, title="Fast EMA")
plot(slow_ema, color=color.red, linewidth=2, title="Slow EMA")
plot(macdLine, color=color.blue, linewidth=2, title="MACD Line")
plot(signalLine, color=color.red, linewidth=2, title="Signal Line")
hline(30, "RSI 30", color=color.green)
hline(70, "RSI 70", color=color.red)
plot(rsi, color=color.purple, linewidth=2, title="RSI")