
이 전략은 다중 지수 이동 평균 (EMA) 과 실제 변동의 폭 (ATR) 을 기반으로 한 트렌드 추적 거래 시스템이다. 이 전략은 20주기, 50주기 및 100주기 3개의 EMA를 협동적으로 조합하여 시장의 트렌드를 포착하고 ATR을 사용하여 역동적인 위험 관리 및 수익 목표를 설정한다. 이 방법은 거래의 체계성을 보장하면서 위험의 역동적인 통제를 실현한다.
이 전략의 핵심 논리는 가격과 다중 EMA 사이의 상호관계에 기초하고 있습니다. 구체적으로:
이 전략은 다중 평평선 시스템과 ATR 동적 풍선 제어의 결합을 통해 트렌드 추적과 파급 동작 특성을 겸비한 거래 시스템을 구축한다. 전략의 장점은 체계성이 강하고 위험 제어 가능하다는 데 있다. 그러나 실제 응용에서는 시장 환경에 대한 적응성에 주의를 기울이고 실제 상황에 따라 타겟팅 최적화가 필요합니다. 합리적인 매개 변수 설정과 엄격한 위험 통제를 통해 이 전략은 대부분의 시장 환경에서 안정적인 거래 효과를 얻을 것으로 예상된다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("EMA Swing Strategy with ATR", overlay=true)
// Inputs
emaShort = input.int(20, "Short EMA")
emaMid = input.int(50, "Mid EMA")
emaLong = input.int(100, "Long EMA")
rrRatio = input.float(1.5, "Risk-Reward Ratio")
contracts = input.int(5, "Number of Contracts")
// Calculations
ema20 = ta.ema(close, emaShort)
ema50 = ta.ema(close, emaMid)
ema100 = ta.ema(close, emaLong)
atr = ta.atr(14)
// Conditions
longCondition = ta.crossover(close, ema20) and close > ema50
shortCondition = ta.crossunder(close, ema20) and close < ema50
// Variables for trades
var float entryPrice = na
var float stopLoss = na
var float takeProfit = na
// Long Trades
if (longCondition)
entryPrice := close
stopLoss := close - atr
takeProfit := close + atr * rrRatio
strategy.entry("Long", strategy.long, contracts)
strategy.exit("Exit Long", from_entry="Long", stop=stopLoss, limit=takeProfit)
// Short Trades
if (shortCondition)
entryPrice := close
stopLoss := close + atr
takeProfit := close - atr * rrRatio
strategy.entry("Short", strategy.short, contracts)
strategy.exit("Exit Short", from_entry="Short", stop=stopLoss, limit=takeProfit)
// Plot EMAs
plot(ema20, color=color.green, title="EMA 20")
plot(ema50, color=color.red, title="EMA 50")
plot(ema100, color=color.white, title="EMA 100")
// Visualization for Entries
plotshape(series=longCondition, style=shape.labelup, color=color.green, location=location.belowbar, title="Long Entry")
plotshape(series=shortCondition, style=shape.labeldown, color=color.red, location=location.abovebar, title="Short Entry")