
이 전략은 5일 지수 이동 평균 ((EMA) 을 기반으로 한 거래 시스템으로, 주로 가격과 평균 사이의 이탈 형태를 식별하고 브레이크 신호를 결합하여 거래를 수행한다. 전략은 즉각적인 실행 메커니즘을 채택하고, K 라인 클로즈 확인을 기다릴 필요가 없으며, 거래의 시간적 효과를 향상시킨다. 시스템은 또한 3 배의 위험과 수익 비율의 동적 중지 손실 관리 메커니즘을 통합한다.
이 전략의 핵심 논리는 다음과 같은 몇 가지 핵심 요소에 기반합니다.
이것은 단기 평균선, 외형 및 돌파 신호를 결합한 통합 거래 전략이다. 즉각적인 실행 메커니즘을 통해 전략의 시간적 효과를 높이고, 동적인 위험 관리 방법을 사용하여 위험을 통제한다. 약간의 잠재적인 위험이 있지만, 적절한 최적화 및 위험 관리 조치를 통해 전략은 더 나은 실용적 가치를 가지고 있다. 거래자는 실전 사용 전에 충분한 재검토를 수행하고, 특정 시장 상황에 따라 적절한 매개 변수를 조정하는 것이 좋습니다.
/*backtest
start: 2024-02-20 00:00:00
end: 2025-01-05 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"DOGE_USDT"}]
*/
//@version=5
strategy("5 EMA (Instant Execution)", overlay=true, margin_long=100, margin_short=100)
// Input parameters
ema_length = input.int(5)
target_multiplier = input.float(3.0)
// Calculate 5 EMA
ema_5 = ta.ema(close, ema_length)
// Detect divergence candles
divergence_buy = (high < ema_5) and (low < ema_5) // Below 5 EMA for buy
divergence_sell = (high > ema_5) and (low > ema_5) // Above 5 EMA for sell
// Store trigger levels dynamically
var float trigger_high = na
var float trigger_low = na
// Set trigger levels when divergence occurs
if divergence_buy
trigger_high := high
if divergence_sell
trigger_low := low
// Check real-time price break (no candle close waiting)
buy_signal = not na(trigger_high) and high >= trigger_high
sell_signal = not na(trigger_low) and low <= trigger_low
// Execute trades instantly
if buy_signal
strategy.entry("Long", strategy.long)
candle_size = trigger_high - low
strategy.exit("Long Exit", "Long", limit=trigger_high + (candle_size * target_multiplier), stop=low)
trigger_high := na // Reset trigger
if sell_signal
strategy.entry("Short", strategy.short)
candle_size = high - trigger_low
strategy.exit("Short Exit", "Short", limit=trigger_low - (candle_size * target_multiplier), stop=high)
trigger_low := na // Reset trigger
// Plot signals
plotshape(buy_signal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(sell_signal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
// Plot 5 EMA
plot(ema_5, color=color.blue, linewidth=2)
// Alert conditions
alertcondition(buy_signal, message="BUY triggered - High of divergence candle broken instantly")
alertcondition(sell_signal, message="SELL triggered - Low of divergence candle broken instantly")