
이 전략은 주로 지수 이동 평균 (EMA), 상대적으로 강한 지수 (RSI) 및 트렌드 방향 지수 (ADX) 를 사용하여 시장 추세를 분석하고 거래 신호를 생성하며 실제 변동의 폭 (ATR) 을 사용하여 동적 중단과 수익 목표를 설정합니다.
이 전략은 다중 기술 지표가 결합된 트렌드 추적 거래 시스템이다. 그것은 주로 가격 트렌드 방향을 결정하는 EMA, 시장 과매매 상태를 판단하는 RSI, 트렌드 강도를 검증하는 ADX, 마지막으로 ATR을 사용하여 포지션 크기와 위험 관리 매개 변수를 동적으로 조정한다. 전략은 여러 가지 포지션 계산 방법을 지원합니다.
이것은 여러 기술적 지표의 종합적인 트렌드 추적 전략이며, 다차원적인 트렌드 확인과 완벽한 위험 관리 메커니즘을 통해 비교적 안정적인 거래를 달성한다. 전략의 장점은 시스템적인 트렌드 확인 장치와 유연한 포지션 관리에 있다. 그러나 또한 지표의 뒤처짐과 시장 환경 적응성 등의 문제에 주의를 기울여야 한다. 지속적인 최적화와 위험 통제의 개선으로 이 전략은 다양한 시장 환경에서 안정적인 성능을 유지할 것으로 보인다.
/*backtest
start: 2025-02-10 00:00:00
end: 2025-02-17 00:00:00
period: 45m
basePeriod: 45m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Momentum Scalper", shorttitle="EMS", overlay=true, pyramiding=0)
// === ПАРАМЕТРЫ ===
posSizeMethod = input.string("Capital %", title="Метод расчета позиции", options=["% Based", "Capital %", "Fixed Capital Based", "Fixed Contract Size"])
riskPerTrade = input.float(3, title="Риск на сделку (%)", minval=0.1, maxval=100, step=0.5) / 100
capitalPctPerTrade = input.float(10, title="Доля капитала на сделку (%)", minval=0.1, maxval=100, step=0.5) / 100
fixedCapitalAmount = input.float(100, title="Фиксированная сумма капитала", minval=0)
fixedContractSize = input.int(10, title="Фиксированный размер контракта")
atrLength = input.int(14, title="Длина ATR")
atrMultiplierSL = input.float(2.5, title="ATR множитель для SL")
atrMultiplierTP = input.float(1.5, title="ATR множитель для TP")
timeoutBars = input.int(20, title="Выход через X баров, если нет TP/SL")
emaLength = input.int(50, title="Длина EMA")
rsiLength = input.int(14, title="Длина RSI")
rsiOverbought = input.int(70, title="RSI перекупленность")
rsiOversold = input.int(30, title="RSI перепроданность")
adxLength = input.int(14, title="Длина ADX")
adxThreshold = input.float(20, title="Порог ADX для тренда")
leverage = input.int(15, title="Плечо", minval=1, maxval=100)
// === ИНДИКАТОРЫ ===
atr = ta.atr(atrLength)
ema = ta.ema(close, emaLength)
rsi = ta.rsi(close, rsiLength)
// === ADX ===
diPlus = ta.rma(math.max(high - high[1], 0), adxLength)
diMinus = ta.rma(math.max(low[1] - low, 0), adxLength)
dx = 100 * math.abs(diPlus - diMinus) / (diPlus + diMinus)
adx = ta.rma(dx, adxLength)
// === УСЛОВИЯ ВХОДА ===
longEntry = ta.crossover(close, ema) and rsi > 50 and adx > adxThreshold
shortEntry = ta.crossunder(close, ema) and rsi < 50 and adx > adxThreshold
// === РАСЧЕТ РАЗМЕРА ПОЗИЦИИ ===
var float qty = na
riskAmount = strategy.equity * riskPerTrade
stopLossDistance = atr * atrMultiplierSL
positionSize = riskAmount / stopLossDistance
if (posSizeMethod == "% Based")
qty := strategy.equity * riskPerTrade / (atr * atrMultiplierSL)
else if (posSizeMethod == "Capital %")
qty := strategy.equity * capitalPctPerTrade / close
else if (posSizeMethod == "Fixed Capital Based")
qty := fixedCapitalAmount / close
else if (posSizeMethod == "Fixed Contract Size")
qty := fixedContractSize
qty := qty * leverage // Умножаем на плечо
// === СТОП-ЛОСС И ТЕЙК-ПРОФИТ ===
entryPrice = close
stopLossLong = entryPrice - atrMultiplierSL * atr
stopLossShort = entryPrice + atrMultiplierSL * atr
takeProfit1 = entryPrice + atrMultiplierTP * atr * (longEntry ? 1 : -1)
takeProfit2 = entryPrice + atrMultiplierTP * atr * (longEntry ? 2 : -2) / 1.5
// === ТРЕЙЛИНГ-СТОП ===
trailStopDistance = atr * atrMultiplierSL
if (longEntry)
strategy.entry("Long", strategy.long, qty=qty)
strategy.exit("Exit Long", "Long", stop=stopLossLong, limit=takeProfit1, trail_points=trailStopDistance)
alertMessage = syminfo.ticker + " LONG\n" +
"Leverage: Cross " + str.tostring(leverage) + "x\n" +
"➡️ Entry: " + str.tostring(entryPrice) + "\n" +
"🟢 Take profit 1: " + str.tostring(takeProfit1) + "\n" +
"🛑 Stop loss: " + str.tostring(stopLossLong)
alert(alertMessage, alert.freq_once_per_bar_close)
if (shortEntry)
strategy.entry("Short", strategy.short, qty=qty)
strategy.exit("Exit Short", "Short", stop=stopLossShort, limit=takeProfit1, trail_points=trailStopDistance)
alertMessage = syminfo.ticker + " SHORT\n" +
"Leverage: Cross " + str.tostring(leverage) + "x\n" +
"➡️ Entry: " + str.tostring(entryPrice) + "\n" +
"🟢 Take profit 1: " + str.tostring(takeProfit1) + "\n" +
"🛑 Stop loss: " + str.tostring(stopLossShort)
alert(alertMessage, alert.freq_once_per_bar_close)
// === ВИЗУАЛИЗАЦИЯ ===
plotshape(longEntry, color=color.green, style=shape.labelup, location=location.belowbar, text="BUY")
plotshape(shortEntry, color=color.red, style=shape.labeldown, location=location.abovebar, text="SELL")
plot(ema, color=color.blue, title="EMA")
bgcolor(rsi > rsiOverbought or rsi < rsiOversold ? color.new(color.gray, 80) : na)