
이 전략은 다중 기술 지표에 기반한 현장 시장 다단계 전략이다. 그것은 주로 빠르고 느린 이동 평균 (EMA) 의 교차 신호를 이용하며, 상대적으로 약한 지수 (RSI), 평균 트렌드 지수 (ADX) 및 이동 평균 동향/방향 지수 (MACD) 를 결합하여 거래 신호를 확인한다. 전략은 또한 평균 실제 파장을 (ATR) 사용하여 동적 스톱 및 정지 수준을 설정하여 위험 관리를 수행한다.
전략의 핵심 논리는 다음과 같은 핵심 구성 요소를 기반으로 합니다.
이는 합리적으로 설계된 트렌드 추적 전략으로, 다수의 기술 지표를 조합하여 위험을 통제하면서 안정적인 수익을 추구한다. 전략의 장점은 완벽한 확인 메커니즘과 위험 관리 시스템이지만, 실제 시장 상황에 따라 변수를 최적화하고 논리를 개선해야 한다. 기존의 위험에 대해 시장 환경 필터링과 최적화 변수를 추가함으로써 전략의 안정성과 수익성을 더욱 향상시킬 수 있다.
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("Optimized Long-Only Strategy (Spot Market) - Candle Signals Only", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.1)
// INPUTS
fastEMA_len = input.int(8, "Fast EMA Length", minval=1)
slowEMA_len = input.int(21, "Slow EMA Length", minval=1)
rsiPeriod = input.int(14, "RSI Period")
rsiOverbought = input.int(70, "RSI Overbought Level", minval=50)
adxPeriod = input.int(14, "ADX Period", minval=1)
adxThreshold = input.int(25, "ADX Trend Strength Threshold", minval=1)
fastMACD = input.int(12, "MACD Fast Length", minval=1)
slowMACD = input.int(26, "MACD Slow Length", minval=1)
signalMACD = input.int(9, "MACD Signal Length", minval=1)
atrPeriod = input.int(14, "ATR Period", minval=1)
atrStopMultiplier = input.float(1.5, "ATR Stop Loss Multiplier", step=0.1)
atrProfitMultiplier = input.float(2.0, "ATR Profit Target Multiplier", step=0.1)
// CALCULATIONS
emaFast = ta.ema(close, fastEMA_len)
emaSlow = ta.ema(close, slowEMA_len)
rsiValue = ta.rsi(close, rsiPeriod)
// --- Custom ADX Calculation ---
up = ta.change(high)
down = -ta.change(low)
plusDM = (up > down and up > 0) ? up : 0
minusDM = (down > up and down > 0) ? down : 0
trueRange = ta.tr(true) // 'handle_na' parameter set to true
atrVal = ta.rma(trueRange, adxPeriod)
plusDI = 100 * ta.rma(plusDM, adxPeriod) / atrVal
minusDI = 100 * ta.rma(minusDM, adxPeriod) / atrVal
dx = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
adxValue = ta.rma(dx, adxPeriod)
// MACD Calculation (MACD line, signal line, histogram)
[macdLine, signalLine, _] = ta.macd(close, fastMACD, slowMACD, signalMACD)
// ATR for stops and targets
atrValue = ta.atr(atrPeriod)
// TRADING CONDITION (Long Only, on confirmed candle)
longCondition = ta.crossover(emaFast, emaSlow) and (adxValue > adxThreshold) and (macdLine > signalLine) and (rsiValue < rsiOverbought)
// POSITION MANAGEMENT: Execute only on confirmed candles
if barstate.isconfirmed and longCondition
strategy.entry("Long", strategy.long)
longStop = close - atrStopMultiplier * atrValue
longTarget = close + atrProfitMultiplier * atrValue
strategy.exit("Long Exit", from_entry="Long", stop=longStop, limit=longTarget, trail_points=atrValue * 0.5, trail_offset=atrValue * 0.3)
// PLOTTING
plot(emaFast, color=color.green, title="Fast EMA")
plot(emaSlow, color=color.red, title="Slow EMA")
plotshape(barstate.isconfirmed and longCondition, title="Buy Signal", style=shape.labelup, location=location.belowbar, color=color.green, text="BUY", textcolor=color.white, size=size.tiny)