
이것은 지수 이동 평균 (EMA) 의 교차와 평균 실제 파도 (ATR) 필터를 결합한 양적 거래 전략이다. 이 전략은 강력한 트렌드를 인식하고 높은 변동률의 시장 환경에서 거래함으로써 전략의 샤프 비율과 전체적인 성능을 효과적으로 향상시킵니다. 이 전략은 50주기 및 200주기의 EMA를 사용하여 중장기 트렌드를 포착하며, ATR 지표를 사용하여 시장의 변동성을 평가하며, 변동률이 특정 경계를 초과 할 때만 거래합니다.
전략의 핵심 논리는 두 가지 주요 부분을 포함합니다: 추세 판단과 변동률 필터링. 추세 판단 측면에서, 전략은 50주기 EMA를 빠른 라인으로, 200주기 EMA를 느린 라인으로 사용하며, 빠른 라인에서 느린 라인을 통과하면 멀티 신호를 생성하고, 하강하면 빈 신호를 생성합니다. 변동률 필터링 측면에서, 전략은 14주기의 ATR 값을 계산하고 그것을 가격의 퍼센트로 변환합니다.
이 전략은 고전적인 기술 지표와 현대적인 리스크 관리 철학을 결합한 전략이다. EMA를 통해 트렌드를 교차 캡처하고, ATR 필터를 사용하여 거래 시기를 제어하는 동시에, 전략은 단순성을 유지하면서도 강력한 실용성을 가지고 있다. 일부 고유한 위험이 존재하지만, 합리적인 최적화 및 위험 관리 조치를 통해 이 전략은 여전히 좋은 응용 가치를 가지고 있다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Crossover with ATR Filter", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// Inputs for Moving Averages
fastLength = input.int(50, title="Fast EMA Length")
slowLength = input.int(200, title="Slow EMA Length")
// Inputs for ATR Filter
atrLength = input.int(14, title="ATR Length")
atrMultiplier = input.float(1.5, title="ATR Multiplier")
atrThreshold = input.float(0.02, title="ATR Threshold (%)")
// Calculate EMAs
fastEMA = ta.ema(close, fastLength)
slowEMA = ta.ema(close, slowLength)
// Calculate ATR
atr = ta.atr(atrLength)
// Convert ATR to a percentage of price
atrPct = atr / close
// Define Long Condition (Cross and ATR filter)
longCondition = ta.crossover(fastEMA, slowEMA) and atrPct > atrThreshold / 100
// Define Short Condition
shortCondition = ta.crossunder(fastEMA, slowEMA) and atrPct > atrThreshold / 100
// Define Exit Conditions
exitConditionLong = ta.crossunder(fastEMA, slowEMA)
exitConditionShort = ta.crossover(fastEMA, slowEMA)
// Long Entry
if (longCondition)
strategy.entry("Long", strategy.long)
// Short Entry
if (shortCondition)
strategy.entry("Short", strategy.short)
// Long Exit
if (exitConditionLong)
strategy.close("Long")
// Short Exit
if (exitConditionShort)
strategy.close("Short")
// Plot EMAs for visual reference
plot(fastEMA, title="50 EMA", color=color.blue)
plot(slowEMA, title="200 EMA", color=color.red)
// Plot ATR for reference
plot(atrPct, title="ATR Percentage", color=color.orange, style=plot.style_line)
hline(atrThreshold / 100, "ATR Threshold", color=color.green)