
이 전략은 단기 지수 이동 평균(EMA) 교차 신호를 기반으로 하는 고빈도 거래 시스템입니다. 단기 시장 변동을 신속히 포착하기 위해 적응형 변동성 추적 메커니즘과 동적 포지션 관리, 엄격한 위험 관리를 결합합니다. 이 전략은 1분이나 5분 등 짧은 시간 단위에서 실행되며, 빈번한 거래 기회를 찾는 활발한 거래자에게 적합합니다.
이 전략의 핵심 논리는 빠른 EMA(3기간)와 느린 EMA(8기간)의 교차 신호에 기초합니다. 빠른 선이 느린 선 아래로 교차하면 긴 신호가 생성되고, 빠른 선이 느린 선 아래로 교차하면 짧은 신호가 생성됩니다. 이 전략은 ATR 지표를 사용하여 시장 변동성을 측정하고 이에 따라 손절매 및 수익 목표를 동적으로 설정합니다. 본 시스템은 고정 계약 수량 거래 및 계정 자본에 따른 동적 포지션 관리라는 두 가지 모드를 지원합니다. 동적 포지션 모드에서는 각 거래의 위험이 계정 자본의 0.5% 이내로 통제됩니다. 이 전략은 1.2배의 위험-보상 비율을 사용하고 이동 손절매에 대한 추적 거리로 ATR의 1.5배를 결합합니다.
이 전략은 단기 EMA 크로스오버 신호와 동적 위험 관리를 결합하여 완전한 고빈도 거래 시스템을 구축합니다. 이 전략의 장점은 빠른 대응과 엄격한 위험 관리이지만, 거짓 신호와 거래 비용과 같은 문제에도 주의를 기울여야 합니다. 지속적인 최적화와 매개변수 조정을 통해 전략은 다양한 시장 환경에 더 잘 적응하고 거래 효율성과 안정성을 개선할 수 있습니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-04 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("High-Frequency EMA Scalping Strategy - Adjustable Contracts", overlay=true, default_qty_type=strategy.fixed, default_qty_value=1)
// Input parameters
fastEmaLength = input.int(3, title="Fast EMA Length", minval=1)
slowEmaLength = input.int(8, title="Slow EMA Length", minval=1)
atrLength = input.int(10, title="ATR Length", minval=1)
riskRewardRatio = input.float(1.2, title="Risk/Reward Ratio", minval=1)
useDynamicPositionSizing = input.bool(false, title="Use Dynamic Position Sizing?")
fixedContracts = input.int(1, title="Number of Contracts (if Fixed)", minval=1) // Fixed number of contracts
// Calculate EMA values
fastEma = ta.ema(close, fastEmaLength)
slowEma = ta.ema(close, slowEmaLength)
// Calculate ATR for dynamic stop-loss and take-profit
atr = ta.atr(atrLength)
// Dynamic position sizing (if enabled)
capital = strategy.equity
riskPerTrade = capital * 0.005 // Risk 0.5% per trade
dynamicTradeQty = riskPerTrade / (atr * 1.5)
// Use fixed or dynamic position sizing
tradeQty = useDynamicPositionSizing ? dynamicTradeQty : fixedContracts
// Entry conditions
longCondition = ta.crossover(fastEma, slowEma)
shortCondition = ta.crossunder(fastEma, slowEma)
// Long trade execution
if longCondition
risk = atr * 1.0
reward = risk * riskRewardRatio
strategy.entry("Long", strategy.long, qty=tradeQty)
strategy.exit("Trailing Stop Long", from_entry="Long", trail_points=atr * 1.5, trail_offset=atr * 1.0)
strategy.exit("Take Profit", from_entry="Long", limit=close + reward, stop=close - risk)
// Short trade execution
if shortCondition
risk = atr * 1.0
reward = risk * riskRewardRatio
strategy.entry("Short", strategy.short, qty=tradeQty)
strategy.exit("Trailing Stop Short", from_entry="Short", trail_points=atr * 1.5, trail_offset=atr * 1.0)
strategy.exit("Take Profit", from_entry="Short", limit=close - reward, stop=close + risk)
// Plot EMA lines for reference
plot(fastEma, color=color.blue, title="Fast EMA")
plot(slowEma, color=color.red, title="Slow EMA")