
이 전략은 중장기 지수 이동 평균 ((EMA) 의 교차를 기반으로 한 거래 시스템으로, 동적 포지션 관리 및 위험 제어 메커니즘을 결합한다. 전략은 21주기 및 55주기 EMA의 교차를 통해 시장 추세를 식별하고, 사용자 지정 된 위험 수익률과 위험 비율에 따라 거래 포지션 크기를 동적으로 조정하여 위험을 정밀하게 제어한다.
이 전략의 핵심 논리는 두 시간 주기 EMA 교차 신호에 기초한다. 21 주기의 EMA가 55 주기의 EMA를 상향으로 넘어가면, 시스템은 상승 추세로 인식하고, 다중 신호를 유발한다. 21 주기의 EMA가 55 주기의 EMA를 상향으로 넘어가면, 시스템은 하향 추세로 인식하고, 공백 신호를 유발한다.
이 전략은 EMA 트렌드 신호와 동적 위험 관리를 결합하여 완전한 거래 시스템을 구축한다. 전략의 핵심 장점은 과학적인 위치 관리 및 위험 제어 장치에 있다. 그러나 여전히 시장 환경과 개인 위험 선호에 따라 적절한 매개 변수를 최적화해야 한다. 제안된 최적화 방향을 통해 전략의 안정성과 수익성이 더욱 향상될 것으로 보인다.
/*backtest
start: 2024-02-21 00:00:00
end: 2024-07-11 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Carlos Humberto Rodríguez Arias
//@version=5
strategy("EMA Crossover Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// EMA periods
MT_EMA = input.int(21, title="Medium Term EMA")
LT_EMA = input.int(55, title="Long Term EMA")
RR = input.float(2.0, title="Risk-Reward Ratio") // User-defined RR
RiskPercent = input.float(1.0, title="Risk Percentage") // User-defined risk percentage
// Calculate EMAs
Signal_MT_EMA = ta.ema(close, MT_EMA)
Signal_LT_EMA = ta.ema(close, LT_EMA)
// Plot EMAs
plot(Signal_MT_EMA, title="Medium Term EMA", color=color.orange, linewidth=2)
plot(Signal_LT_EMA, title="Long Term EMA", color=color.blue, linewidth=2)
// Determine trend conditions
uptrend = ta.crossover(Signal_MT_EMA, Signal_LT_EMA)
downtrend = ta.crossunder(Signal_MT_EMA, Signal_LT_EMA)
// Stop-Loss Calculations
longStopLoss = ta.lowest(low, 2) // SL for buy = lowest low of last 2 candles
shortStopLoss = ta.highest(high, 2) // SL for sell = highest high of last 2 candles
// Take-Profit Calculations
longTakeProfit = close + (close - longStopLoss) * RR
shortTakeProfit = close - (shortStopLoss - close) * RR
// Calculate Position Size based on Risk Percentage
capital = strategy.equity * (RiskPercent / 100)
longPositionSize = capital / (close - longStopLoss)
shortPositionSize = capital / (shortStopLoss - close)
// Execute Buy Order
if uptrend
strategy.entry("Long", strategy.long, qty=longPositionSize)
strategy.exit("Long Exit", from_entry="Long", stop=longStopLoss, limit=longTakeProfit)
// Execute Sell Order
if downtrend
strategy.entry("Short", strategy.short, qty=shortPositionSize)
strategy.exit("Short Exit", from_entry="Short", stop=shortStopLoss, limit=shortTakeProfit)