
이는 동력과 추세를 결합한 거래 전략으로, 여러 지수 이동 평균 (EMA), 상대적으로 강한 지수 (RSI) 및 무작위 지수 (Stochastic) 를 통해 시장의 추세와 동력을 식별한다. 이 전략은 또한 동적 중지, 수익 목표 및 추적 중지 기능을 포함하는 평균 실제 파동 (ATR) 에 기반한 위험 관리 시스템을 통합하고 있으며, 위험 기반의 위치 관리 방법을 사용합니다.
전략은 5개의 다른 주기적인 EMA를 사용하여 트렌드 방향을 결정한다. 더 짧은 기간의 EMA가 더 긴 기간의 EMA 위에 있을 때, 상승 추세로 인식된다. 반대로 하향 추세이다. RSI는 동력을 확인하기 위해 사용되며, 다른 입출입 및 출출입 마이너스를 설정한다.
이 전략은 다중 기술 지표와 완벽한 위험 관리 시스템을 결합하여 포괄적 인 거래 솔루션을 제공합니다. 그것의 핵심 장점은 다층의 필터링 메커니즘과 동적 위험 관리이지만 특정 시장 특성에 따라 여전히 최적화가 필요합니다. 전략의 성공적인 실행은 지속적인 모니터링과 조정, 특히 다른 시장 환경에서 변수의 적응력이 필요합니다. 제안된 최적화 방향으로 전략은 안정성과 수익성을 더욱 향상시킬 잠재력이 있습니다.
/*backtest
start: 2024-11-04 00:00:00
end: 2024-12-04 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Combined Strategy (Modernized)", overlay = true)
//----------//
// MOMENTUM //
//----------//
ema8 = ta.ema(close, 8)
ema13 = ta.ema(close, 13)
ema21 = ta.ema(close, 21)
ema34 = ta.ema(close, 34)
ema55 = ta.ema(close, 55)
// Plotting EMAs for visualization
plot(ema8, color=color.red, title="EMA 8", linewidth=1)
plot(ema13, color=color.orange, title="EMA 13", linewidth=1)
plot(ema21, color=color.yellow, title="EMA 21", linewidth=1)
plot(ema34, color=color.aqua, title="EMA 34", linewidth=1)
plot(ema55, color=color.lime, title="EMA 55", linewidth=1)
longEmaCondition = ema8 > ema13 and ema13 > ema21 and ema21 > ema34 and ema34 > ema55
exitLongEmaCondition = ema13 < ema55
shortEmaCondition = ema8 < ema13 and ema13 < ema21 and ema21 < ema34 and ema34 < ema55
exitShortEmaCondition = ema13 > ema55
// ---------- //
// OSCILLATORS //
// ----------- //
rsi = ta.rsi(close, 14)
longRsiCondition = rsi < 70 and rsi > 40
exitLongRsiCondition = rsi > 70
shortRsiCondition = rsi > 30 and rsi < 60
exitShortRsiCondition = rsi < 30
// Stochastic
k = ta.stoch(close, high, low, 14)
d = ta.sma(k, 3)
longStochasticCondition = k < 80
exitLongStochasticCondition = k > 95
shortStochasticCondition = k > 20
exitShortStochasticCondition = k < 5
//----------//
// STRATEGY //
//----------//
// ATR for dynamic stop loss and take profit
atr = ta.atr(14)
stopLossMultiplier = 2
takeProfitMultiplier = 4
stopLoss = atr * stopLossMultiplier
takeProfit = atr * takeProfitMultiplier
// Trailing stop settings
trailStopMultiplier = 1.5
trailOffset = atr * trailStopMultiplier
// Risk management: dynamic position sizing
riskPerTrade = 0.01 // 1% risk per trade
positionSize = strategy.equity * riskPerTrade / stopLoss
longCondition = longEmaCondition and longRsiCondition and longStochasticCondition and strategy.position_size == 0
exitLongCondition = (exitLongEmaCondition or exitLongRsiCondition or exitLongStochasticCondition) and strategy.position_size > 0
if (longCondition)
strategy.entry("LONG", strategy.long, qty=positionSize)
strategy.exit("Take Profit Long", "LONG", stop=close - stopLoss, limit=close + takeProfit, trail_offset=trailOffset)
if (exitLongCondition)
strategy.close("LONG")
shortCondition = shortEmaCondition and shortRsiCondition and shortStochasticCondition and strategy.position_size == 0
exitShortCondition = (exitShortEmaCondition or exitShortRsiCondition or exitShortStochasticCondition) and strategy.position_size < 0
if (shortCondition)
strategy.entry("SHORT", strategy.short, qty=positionSize)
strategy.exit("Take Profit Short", "SHORT", stop=close + stopLoss, limit=close - takeProfit, trail_offset=trailOffset)
if (exitShortCondition)
strategy.close("SHORT")