
이 전략은 지수 이동 평균 (EMA), 상대적으로 강한 지수 (RSI) 및 평균 실제 파장 (ATR) 과 같은 기술 지표를 결합 한 다중 지수 통합 거래 시스템이며, 평균 트렌드 지수 (ADX) 를 도입하여 트렌드 판단의 정확성을 강화합니다. 시스템은 여러 신호를 통해 포지션을 설정 할 때를 확인하고, ATR을 사용하여 동적 스톱 및 스톱을 관리하여 위험을 효과적으로 제어합니다.
전략의 핵심은 여러 기술 지표의 조합을 통해 시장 추세를 포착하고 거래하는 것입니다. 구체적으로 다음을 포함합니다:
이 전략은 다중 기술 지표의 유기적 결합을 통해 전체적인 트렌드 추적 거래 시스템을 구축한다. 전략은 거래의 정확성을 보장하면서 엄격한 위험 통제를 통해 거래의 안전을 보장한다. 약간의 최적화 공간이 있지만 전체적인 프레임워크는 좋은 실용적 가치와 확장성을 가지고 있다.
/*backtest
start: 2025-01-20 00:00:00
end: 2025-01-31 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Binance","currency":"DOGE_USDT"}]
*/
//@version=5
strategy("Enhanced GBP/USD Strategy with ADX", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=1)
// === Input Parameters ===
emaFastLength = input.int(20, title="Fast EMA Length")
emaSlowLength = input.int(50, title="Slow EMA Length")
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought")
rsiOversold = input.int(30, title="RSI Oversold")
atrLength = input.int(14, title="ATR Length")
adxLength = input.int(14, title="ADX Length")
riskToReward = input.float(2.0, title="Risk-Reward Ratio (R:R)")
slMultiplier = input.float(1.5, title="SL Multiplier (ATR)")
// === Indicator Calculations ===
emaFast = ta.ema(close, emaFastLength)
emaSlow = ta.ema(close, emaSlowLength)
rsi = ta.rsi(close, rsiLength)
atr = ta.atr(atrLength)
// === ADX Calculation ===
// Components of ADX
tr = ta.rma(ta.tr, adxLength) // True Range smoothed
plusDM = ta.rma(math.max(high - high[1], 0), adxLength) // +DM
minusDM = ta.rma(math.max(low[1] - low, 0), adxLength) // -DM
plusDI = (plusDM / tr) * 100
minusDI = (minusDM / tr) * 100
dx = math.abs(plusDI - minusDI) / (plusDI + minusDI) * 100
adx = ta.rma(dx, adxLength) // Final ADX value
// === Entry Conditions ===
isUptrend = emaFast > emaSlow and adx > 20
isDowntrend = emaFast < emaSlow and adx > 20
buySignal = isUptrend and ta.crossover(rsi, rsiOversold)
sellSignal = isDowntrend and ta.crossunder(rsi, rsiOverbought)
// === Stop-Loss and Take-Profit ===
slDistance = atr * slMultiplier
tpDistance = slDistance * riskToReward
buySL = buySignal ? close - slDistance : na
buyTP = buySignal ? close + tpDistance : na
sellSL = sellSignal ? close + slDistance : na
sellTP = sellSignal ? close - tpDistance : na
// === Execute Trades ===
if buySignal
strategy.entry("Buy", strategy.long)
strategy.exit("Buy TP/SL", from_entry="Buy", stop=buySL, limit=buyTP)
if sellSignal
strategy.entry("Sell", strategy.short)
strategy.exit("Sell TP/SL", from_entry="Sell", stop=sellSL, limit=sellTP)
// === Plotting ===
plot(emaFast, title="Fast EMA", color=color.blue)
plot(emaSlow, title="Slow EMA", color=color.orange)
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
plot(buySL, title="Buy Stop Loss", color=color.red, linewidth=1)
plot(buyTP, title="Buy Take Profit", color=color.green, linewidth=1)
plot(sellSL, title="Sell Stop Loss", color=color.red, linewidth=1)
plot(sellTP, title="Sell Take Profit", color=color.green, linewidth=1)
// === Alerts ===
alertcondition(buySignal, title="Buy Alert", message="Buy Signal Detected!")
alertcondition(sellSignal, title="Sell Alert", message="Sell Signal Detected!")