
이 전략은 다중 지수 이동 평균 ((EMA) 의 교차 신호를 기반으로 한 거래 시스템이며, 다른 주기의 EMA 지표와 ATR 동적 중지 메커니즘을 결합합니다. 전략은 10주기, 39주기, 73주기의 EMA를 주요 신호 지표로 사용하고, 143주기의 고시간 주기 EMA를 트렌드 필터로 도입하고, ATR 지표의 동적 중지 및 수익 목표를 설정합니다.
전략의 핵심 논리는 여러 EMA의 교차 신호와 트렌드 확인을 기반으로 한다. 단기 EMA (10주기) 가 중기 EMA (39주기) 를 상향으로 넘어가고 가격이 장기 EMA (73주기) 와 더 높은 시간 주기 EMA (143주기) 의 위에 있을 때, 시스템은 다중 신호를 발생시킨다. 반대로, 단기 EMA가 중기 EMA를 상향으로 넘어가고 가격이 장기 EMA와 더 높은 시간 주기 EMA의 밑에 있을 때, 시스템은 공백 신호를 발생시킨다. 전략은 ATR의 1배를 스톱 거리로, 2배를 수익 목표로, 위험과 수익의 비율을 1:2의 역동적인 포지션 관리로 사용한다.
이 전략은 다중 EMA 교차로 ATR 동적 중지와 결합하여 트렌드 추적과 위험 관리를 겸비한 거래 시스템을 구축한다. 전략의 주요 장점은 여러 시간 주기 확인 메커니즘과 동적 포지션 관리에 있다. 그러나 수평 시장과 지연성으로 인한 위험에 주의를 기울여야 한다. 거래량 확인, 트렌드 강도 필터링과 같은 최적화 수단을 도입함으로써 전략의 안정성과 수익 능력을 더욱 향상시킬 수 있다. 실제 응용에서는 다양한 시장 환경과 거래 품목 특성에 따라 파라미터를 적절히 조정하는 것이 좋습니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-28 00:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Enhanced EMA Crossover Strategy", overlay=true)
// Define the EMA lengths
ema_short_length = 10
ema_long_length = 39
ema_filter_length = 73
ema_higher_tf_length = 143
// Calculate the EMAs
ema_short = ta.ema(close, ema_short_length)
ema_long = ta.ema(close, ema_long_length)
ema_filter = ta.ema(close, ema_filter_length)
ema_higher_tf = request.security(syminfo.tickerid, "D", ta.ema(close, ema_higher_tf_length))
// Calculate ATR for volatility-based stop loss and take profit
atr_length = 14
atr = ta.atr(atr_length)
// Plot the EMAs
plot(ema_short, title="EMA 10", color=color.blue)
plot(ema_long, title="EMA 35", color=color.red)
plot(ema_filter, title="EMA 75", color=color.orange)
plot(ema_higher_tf, title="EMA Higher TF", color=color.purple)
// EMA crossover conditions with EMA 75 and higher timeframe EMA filter
longCondition = ta.crossover(ema_short, ema_long) and close > ema_filter and close > ema_higher_tf
shortCondition = ta.crossunder(ema_short, ema_long) and close < ema_filter and close < ema_higher_tf
// Execute long trade with dynamic stop loss and take profit
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit/Stop Loss", "Long", limit=close + 2 * atr, stop=close - 1 * atr)
// Execute short trade with dynamic stop loss and take profit
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("Take Profit/Stop Loss", "Short", limit=close - 2 * atr, stop=close + 1 * atr)
// Plot signals on the chart
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL")