이 전략은 두 지수 이동 평균 (EMA) 의 교차를 주요 거래 신호로 사용하며, 상대적으로 약한 지수 (RSI), 이동 평균 분산 지수 (MACD) 및 평균 실제 진폭 (ATR) 을 보조 지표로 사용하여 거래 신호의 신뢰성을 높인다. 빠른 EMA 상에서 느린 EMA를 통과하고 RSI가 70보다 낮으면 MACD 라인이 신호 위에 있고 ATR 값이 이전 주기에 비해 10% 이상 상승하면 다중 신호를 생성한다. 반대로, 빠른 EMA 아래에서 느린 EMA를 통과하고 RSI가 30보다 높으면 MACD 라인이 신호 밑에서 ATR 값이 이전 주기에 비해 10% 이상 상승하면 공백 신호를 생성한다.
이 전략은 EMA, RSI, MACD 및 ATR과 같은 여러 기술 지표를 결합하여 신뢰성있는 거래 신호를 생성하고 고정 점수를 설정하여 위험을 제어합니다. 이 전략에는 몇 가지 결함이 있지만, 더 많은 지표를 도입하고, 스톱 스톱을 최적화하고, 기본 분석을 결합하는 것과 같은 추가적인 최적화 및 개선으로 전략의 성능을 향상시킬 수 있습니다.
/*backtest
start: 2024-03-01 00:00:00
end: 2024-03-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Enhanced EMA Crossover Strategy", overlay=true)
// Indicators
ema_fast = ema(close, 8)
ema_slow = ema(close, 14)
rsi = rsi(close, 14)
// Correcting the MACD variable definitions
[macd_line, signal_line, _] = macd(close, 12, 26, 9)
atr_value = atr(14)
// Entry conditions with additional filters
long_condition = crossover(ema_fast, ema_slow) and rsi < 70 and (macd_line > signal_line) and atr_value > atr_value[1] * 1.1
short_condition = crossunder(ema_fast, ema_slow) and rsi > 30 and (macd_line < signal_line) and atr_value > atr_value[1] * 1.1
// Adding debug information
plotshape(series=long_condition, color=color.green, location=location.belowbar, style=shape.xcross, title="Long Signal")
plotshape(series=short_condition, color=color.red, location=location.abovebar, style=shape.xcross, title="Short Signal")
// Risk management based on a fixed number of points
stop_loss_points = 100
take_profit_points = 200
// Order execution
if (long_condition)
strategy.entry("Long", strategy.long, comment="Long Entry")
strategy.exit("Exit Long", "Long", stop=close - stop_loss_points, limit=close + take_profit_points)
if (short_condition)
strategy.entry("Short", strategy.short, comment="Short Entry")
strategy.exit("Exit Short", "Short", stop=close + stop_loss_points, limit=close - take_profit_points)
// Plotting EMAs for reference
plot(ema_fast, color=color.blue, title="Fast EMA")
plot(ema_slow, color=color.orange, title="Slow EMA")