
이는 다중 지수 이동 평균(EMA) 교차를 기반으로 하는 추세 추종 전략입니다. 이 전략은 10기간 단기 EMA, 50기간 중기 EMA, 200기간 장기 EMA의 교차 관계를 활용하여 시장 동향을 포착하고 조건이 충족되면 롱 및 숏 거래를 시작합니다. 전략의 핵심 아이디어는 여러 시간 단위의 이동 평균을 통해 시장 노이즈를 걸러내고, 주요 추세 방향을 파악하며, 추세가 계속될 때 수익을 창출하는 것입니다.
이 전략은 거래 신호 생성 메커니즘으로 삼중 EMA 교차 시스템을 사용합니다. 구체적으로:
이 전략은 고전적인 추세 추적 시스템입니다. 여러 EMA를 조정하여 사용하면 주요 추세를 파악할 수 있을 뿐만 아니라 적시에 손익 손절매를 할 수 있습니다. 어느 정도 지연이 발생하더라도, 적절한 매개변수 설정과 위험 관리를 통해 추세 시장에서도 안정적인 수익을 얻을 수 있습니다. 전략을 최적화할 수 있는 여지가 많으며, 다른 기술 지표를 도입하고 거래 규칙을 개선하면 성과를 개선할 수 있습니다.
/*backtest
start: 2024-12-10 00:00:00
end: 2025-01-09 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=5
strategy("EMA Crossover Strategy (Enhanced Debug)", overlay=true)
// Inputs for EMA periods
shortEMA = input.int(10, title="Short EMA Period")
mediumEMA = input.int(50, title="Medium EMA Period")
longEMA = input.int(200, title="Long EMA Period")
// Calculating EMAs
emaShort = ta.ema(close, shortEMA)
emaMedium = ta.ema(close, mediumEMA)
emaLong = ta.ema(close, longEMA)
// Plot EMAs
plot(emaShort, color=color.green, title="Short EMA")
plot(emaMedium, color=color.blue, title="Medium EMA")
plot(emaLong, color=color.red, title="Long EMA")
// Conditions for entry and exit
longCondition = close > emaLong and ta.crossover(emaShort, emaMedium) and emaMedium > emaLong
shortCondition = close < emaLong and ta.crossunder(emaShort, emaMedium) and emaMedium < emaLong
closeLongCondition = ta.crossunder(emaShort, emaMedium)
closeShortCondition = ta.crossover(emaShort, emaMedium)
// Debugging labels for unexpected behavior
if (ta.crossover(emaShort, emaLong) and not ta.crossover(emaShort, emaMedium))
label.new(bar_index, high, "Short > Long", style=label.style_circle, color=color.red, textcolor=color.white)
// Debugging EMA relationships
if (emaMedium <= emaLong)
label.new(bar_index, high, "Medium < Long", style=label.style_cross, color=color.orange, textcolor=color.white)
// Entry logic
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
// Exit logic
if (closeLongCondition)
strategy.close("Long")
if (closeShortCondition)
strategy.close("Short")
// Display labels for signals
plotshape(series=longCondition, style=shape.labelup, color=color.green, location=location.belowbar, title="Buy Signal")
plotshape(series=shortCondition, style=shape.labeldown, color=color.red, location=location.abovebar, title="Sell Signal")