
EMA/MACD/RSI 교차 전략은 여러 기술 지표를 결합한 양적 거래 전략이다. 이 전략은 주로 지수 이동 평균 ((EMA), 이동 평균 동향 분산 지표 ((MACD) 및 상대적으로 강한 지수 ((RSI) 의 교차 신호를 사용하여 시장 추세를 판단하고 거래 신호를 생성한다. 전략은 또한 동적 스톱 손실을 설정하고 위험을 효과적으로 제어하기 위해 평균 실제 파장을 ((ATR) 도입했다.
이 전략의 핵심 원칙은 여러 지표의 교차 및 조합을 통해 입출장 및 출장 시간을 결정하는 것입니다.
구매 조건은 빠른 EMA에서 느린 EMA 또는 MACD 라인을 통과하는 신호 라인을 통과하는 것과 동시에 RSI가 초과 판매 수준보다 높습니다. 판매 조건은 반대입니다. 전략은 또한 재개 포지션을 피하기 위해 현재의 포지션 상태를 확인하여 자금 활용 효율성을 높입니다.
EMA/MACD/RSI 크로스 전략은 다중 지표의 연동으로 거래 기회를 식별하고 위험을 관리하는 포괄적인 기술 분석 거래 시스템입니다. 이 전략의 주요 장점은 다차원 시장 분석 관점과 유연한 위험 관리 장치입니다. 그러나 사용자는 다양한 시장 환경에서 전략의 성과 차이에 주의를 기울이고 특정 거래 품종과 시장 상황에 대한 매개 변수를 최적화해야합니다.
/*backtest
start: 2024-10-06 00:00:00
end: 2024-10-13 00:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Mister Buy / sell signals", overlay=true, shorttitle="Mister Buy / sell signals")
// ─────────────────────────────────────────────────────────────
// Paramètres des EMA et adaptation selon le timeframe
ema_fast_length = input(3, title="EMA Rapide (12)")
ema_slow_length = input(4, title="EMA Lente (26)")
ema_long_length = input(5, title="EMA Longue (50)")
// Paramètres MACD
macd_fast_length = input(1, title="MACD Période Rapide")
macd_slow_length = input(2, title="MACD Période Lente")
macd_signal_length = input(3, title="MACD Signal (9)")
// Paramètres RSI
rsi_length = input(42, title="RSI Période")
rsi_overbought = input(70, title="RSI Zone de surachat")
rsi_oversold = input(30, title="RSI Zone de survente")
// Paramètres ATR
atr_length = input(12, title="ATR Période")
atr_multiplier = input(1.0, title="Multiplicateur ATR pour Stop")
// ─────────────────────────────────────────────────────────────
// Calcul des EMA
ema_fast = ta.ema(close, ema_fast_length)
ema_slow = ta.ema(close, ema_slow_length)
ema_long = ta.ema(close, ema_long_length)
// Calcul du RSI
rsi = ta.rsi(close, rsi_length)
// Calcul du MACD
[macdLine, signalLine, _] = ta.macd(close, macd_fast_length, macd_slow_length, macd_signal_length)
// Calcul de l'ATR pour gérer les stops
atr_value = ta.atr(atr_length)
// ─────────────────────────────────────────────────────────────
// Conditions d'achat et de vente basées sur MACD, EMA et RSI
buy_condition = (ta.crossover(ema_fast, ema_slow) or ta.crossover(macdLine, signalLine)) and rsi > rsi_oversold
sell_condition = (ta.crossunder(ema_fast, ema_slow) or ta.crossunder(macdLine, signalLine)) and rsi < rsi_overbought
// ─────────────────────────────────────────────────────────────
// Vérification des positions ouvertes pour éviter les doublons
long_position = strategy.position_size > 0 // Position d'achat ouverte
short_position = strategy.position_size < 0 // Position de vente ouverte
// ─────────────────────────────────────────────────────────────
// Gestion des positions et Stop Loss
long_stop = close - atr_value * atr_multiplier
short_stop = close + atr_value * atr_multiplier
// Entrer les positions uniquement si aucune position n'est ouverte dans la même direction
if (buy_condition and not long_position)
strategy.entry("Buy", strategy.long)
strategy.exit("Exit Buy", from_entry="Buy", stop=long_stop)
if (sell_condition and not short_position)
strategy.entry("Sell", strategy.short)
strategy.exit("Exit Sell", from_entry="Sell", stop=short_stop)
// ─────────────────────────────────────────────────────────────
// Affichage des EMA et du MACD sur le graphique
plot(ema_fast, color=color.green, linewidth=2, title="EMA Rapide (12)")
plot(ema_slow, color=color.red, linewidth=2, title="EMA Lente (26)")
plot(ema_long, color=color.blue, linewidth=1, title="EMA Longue (50)")
plot(macdLine, color=color.green, title="MACD Line")
plot(signalLine, color=color.red, title="MACD Signal Line")
// ─────────────────────────────────────────────────────────────
// Signaux graphiques pour les points d'entrée et de sortie
// Affichage des signaux d'achat si aucune position Buy n'est active
plotshape(series=buy_condition and not long_position, title="Signal Achat", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", textcolor=color.white)
// Affichage des signaux de vente si aucune position Sell n'est active
plotshape(series=sell_condition and not short_position, title="Signal Vente", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", textcolor=color.white)