지능형 다차원 적응형 트렌드 거래 시스템

FVG RSI MACD VWAP EMA ATR supertrend
생성 날짜: 2025-02-21 11:37:36 마지막으로 수정됨: 2025-02-21 11:37:36
복사: 0 클릭수: 483
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

지능형 다차원 적응형 트렌드 거래 시스템 지능형 다차원 적응형 트렌드 거래 시스템

개요

이 전략은 다중 기술 지표를 결합한 지능형 거래 시스템으로, 공정 가치 격차 (FVG), 트렌드 신호 및 가격 행동에 대한 통합 분석을 통해 시장 기회를 식별합니다. 이 시스템은 트렌드 추적과 대역 거래 특성을 결합한 이중 전략 메커니즘을 사용하여, 동적 포지션 관리 및 다차원 퇴출 메커니즘을 통해 거래 성능을 최적화합니다. 이 전략은 특히 위험 통제에 초점을 맞추고, 변동률 필터링 및 거래량 확인을 통해 신호 품질을 향상시킵니다.

전략 원칙

전략의 핵심 논리는 다음과 같은 차원에 기반합니다.

  1. FVG 격차 식별 - 가격 점프 격차의 크기를 계산하여 잠재적인 거래 기회를 찾습니다.
  2. 트렌드 확인 시스템 - 200 일간 평균선, 슈퍼 트렌드 지표 및 MACD와 결합하여 시장 추세를 확인합니다.
  3. 스마트 자금 확인 - 거래 트리거 조건으로 RSI 과잉 구매 과잉 판매, 거래량 이상 및 가격 행동 패턴을 사용
  4. 다이내믹 포지션 관리 - ATR 기반의 변동률을 통해 포지션 크기를 조정하여 리스크 의 일관성을 보장합니다.
  5. 다단계 탈퇴 메커니즘 - 트래킹 스톱로스와 목표 스톱을 결합하여 거래 탈퇴를 관리하는 방법

전략적 이점

  1. 적응력 - 전략은 시장의 변동에 따라 매개 변수와 포지션을 자동으로 조정할 수 있습니다.
  2. 리스크 관리가 완벽합니다. 여러 필터와 엄격한 포지션 관리로 리스크를 제어합니다.
  3. 신호 품질 안정성 - 다차원 지표 확인으로 거래 신호의 정확성을 향상
  4. 유연한 거래방식 - 동시 동향과 변동의 기회를 잡을 수 있습니다.
  5. 재무 관리 과학 - 재무 사용의 합리성을 보장하는 비율 위험 관리

전략적 위험

  1. 매개 변수 민감성 - 여러 매개 변수의 설정이 정책 성능에 영향을 줄 수 있으며 지속적인 최적화가 필요합니다.
  2. 시장 환경 의존성 - 일부 시장 환경에서는 가짜 돌파 신호가 발생할 수 있습니다.
  3. 슬라이드 효과 - 유동성이 낮은 시장에서 더 큰 슬라이드가 발생할 수 있습니다.
  4. 계산 복잡성 - 여러 지표의 계산은 신호 지연을 초래할 수 있습니다.
  5. 높은 자본 요구 - 완전한 실행 전략은 큰 초기 자본 규모가 필요합니다.

전략 최적화 방향

  1. 지표 무게 최적화 - 각 지표의 무게를 동적으로 조정하는 기계 학습 방법을 도입할 수 있습니다.
  2. 시장 적응력 강화 - 시장의 변동성을 증가시키는 적응 장치
  3. 신호 필터링 개선 - 더 많은 시장 미시 구조 지표 도입
  4. 실행 메커니즘 최적화 - 지능형 주문 분할 메커니즘을 추가하여 충격 비용을 절감
  5. 위험 관리 업그레이드 - 동적 위험 예산 관리 시스템을 추가

요약하다

이 전략은 여러 가지 기술 지표와 거래 기술을 통합하여 완전한 거래 시스템을 구축한다. 이 전략은 시장 변화에 적응할 수 있으며 엄격한 위험 통제를 유지한다는 장점이 있다. 약간의 최적화 공간이 있지만 전체적으로 합리적으로 설계된 양적 거래 전략이다.

전략 소스 코드
/*backtest
start: 2025-01-01 00:00:00
end: 2025-02-20 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/

//@version=6
strategy("Adaptive Trend Signals", overlay=true, margin_long=100, margin_short=100, pyramiding=1, initial_capital=50000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.075)

// 1. Enhanced Inputs with Debugging Options

fvgSize = input.float(0.25, "FVG Size (%)", minval=0.1, step=0.05)
atrPeriod = input.int(14, "ATR Period")  // Increased for better stability
rsiPeriod = input.int(7, "RSI Period")
useSuperTrend = input.bool(true, "Use SuperTrend Filter")
useTrendFilter = input.bool(false, "Use 200 EMA Trend Filter")  // Disabled by default
volatilityThreshold = input.float(1.0, "Volatility Threshold (ATR%)", step=0.1)  // Increased threshold
useVolume = input.bool(true, "Use Volume Confirmation")
riskPercentage = input.float(2.0, "Risk %", minval=0.1, maxval=5)

// 2. Advanced Market Filters with Trend Change Detection
var int marketTrend = 0
var bool trendChanged = false
ema200 = ta.ema(close, 200)
prevMarketTrend = marketTrend
marketTrend := close > ema200 ? 1 : close < ema200 ? -1 : 0
trendChanged := marketTrend != prevMarketTrend

// 3. Enhanced FVG Detection with Adjusted Volume Requirements
bullishFVG = (low[1] > high[2] and (low[1] - high[2])/high[2]*100 >= fvgSize) or 
             (low > high[1] and (low - high[1])/high[1]*100 >= fvgSize)

bearishFVG = (high[1] < low[2] and (low[2] - high[1])/low[2]*100 >= fvgSize) or 
             (high < low[1] and (low[1] - high)/low[1]*100 >= fvgSize)

// 4. Smart Money Confirmation System with Signal Debugging
rsi = ta.rsi(close, rsiPeriod)
[macdLine, signalLine, _] = ta.macd(close, 5, 13, 5)
[supertrendLine, supertrendDir] = ta.supertrend(3, 10)

// Script 2 Indicators
[macdLine2, signalLine2, _] = ta.macd(close, 4, 11, 3)
[supertrendLine2, supertrendDir2] = ta.supertrend(3, 7)
vWAP = ta.vwap(close)
ema21 = ta.ema(close, 21)

// 5. Price Action Filters from Script 2
breakoutLong = close > ta.highest(high, 5) and (useVolume ? volume > ta.sma(volume, 10)*1.8 : true)
breakdownShort = close < ta.lowest(low, 5) and (useVolume ? volume > ta.sma(volume, 10)*1.8 : true)
bullishRejection = low < vWAP and close > (high + low)/2 and close > open
bearishRejection = high > vWAP and close < (high + low)/2 and close < open

// 6. Combined Entry Conditions
longBaseCond = (bullishFVG and rsi < 35 and macdLine > signalLine) or
              (bullishFVG and rsi < 38 and supertrendDir2 == 1) or
              (breakoutLong and macdLine2 > signalLine2) or
              (bullishRejection and close > ema21)

shortBaseCond = (bearishFVG and rsi > 65 and macdLine < signalLine) or
               (bearishFVG and rsi > 62 and supertrendDir2 == -1) or
               (breakdownShort and macdLine2 < signalLine2) or
               (bearishRejection and close < ema21)

longSignal = longBaseCond and (not useSuperTrend or supertrendDir == 1) and (not useTrendFilter or marketTrend == 1)

shortSignal = shortBaseCond and (not useSuperTrend or supertrendDir == -1) and (not useTrendFilter or marketTrend == -1)

// 7. Position Sizing with Minimum Quantity
var float longEntryPrice = na
var float shortEntryPrice = na
atr = ta.atr(atrPeriod)
positionSizeScript1 = math.max(strategy.equity * riskPercentage / 100 / (atr * 1.5), 1)
positionSizeScript2 = strategy.equity * riskPercentage / 100 / (atr * 2)

// 8. Dynamic Exit System with Dual Strategies
var float trailPrice = na
if longSignal or trendChanged and marketTrend == 1
    trailPrice := close
if shortSignal or trendChanged and marketTrend == -1
    trailPrice := close

trailOffset = atr * 0.75

// Script 1 Exit Logic
if strategy.position_size > 0
    trailPrice := math.max(trailPrice, close)
    strategy.exit("Long Exit", "Long", stop=trailPrice - trailOffset, trail_offset=trailOffset)
    
if strategy.position_size < 0
    trailPrice := math.min(trailPrice, close)
    strategy.exit("Short Exit", "Short", stop=trailPrice + trailOffset, trail_offset=trailOffset)

// Script 2 Exit Logic
longStop = close - atr * 1.2
shortStop = close + atr * 1.2
strategy.exit("Long Exit 2", "Long", stop=longStop, limit=na(longEntryPrice) ? na : longEntryPrice + (atr * 4), trail_points=not na(longEntryPrice) and close > longEntryPrice + atr ? atr * 3 : na, trail_offset=atr * 0.8)
strategy.exit("Short Exit 2", "Short", stop=shortStop, limit=na(shortEntryPrice) ? na : shortEntryPrice - (atr * 4), trail_points=not na(shortEntryPrice) and close < shortEntryPrice - atr ? atr * 3 : na, trail_offset=atr * 0.8)

// 9. Trend Change Signals and Visuals
// plot(supertrendLine, "SuperTrend", color=color.new(#2962FF, 0))
// plot(supertrendLine2, "SuperTrend 2", color=color.new(#FF00FF, 0))
// plot(ema200, "200 EMA", color=color.new(#FF6D00, 0))
// plot(ema21, "21 EMA", color=color.new(#00FFFF, 0))

bgcolor(marketTrend == 1 ? color.new(color.green, 90) : 
       marketTrend == -1 ? color.new(color.red, 90) : na)

plotshape(trendChanged and marketTrend == 1, "Bullish Trend", shape.labelup, 
         location.belowbar, color=color.green, text="▲ Trend Up")
plotshape(trendChanged and marketTrend == -1, "Bearish Trend", shape.labeldown, 
         location.abovebar, color=color.red, text="▼ Trend Down")

// 10. Signal Visualization for Both Strategies
// plotshape(longSignal, "Long Entry", shape.triangleup, location.belowbar, 
//          color=color.new(#00FF00, 0), size=size.small)
// plotshape(shortSignal, "Short Entry", shape.triangledown, location.abovebar, 
//          color=color.new(#FF0000, 0), size=size.small)
// plotshape(breakoutLong, "Breakout Long", shape.flag, location.belowbar, 
//          color=color.new(#00FF00, 50), size=size.small)
// plotshape(breakdownShort, "Breakdown Short", shape.flag, location.abovebar, 
//          color=color.new(#FF0000, 50), size=size.small)

// 11. Order Execution with Dual Entry Systems
if trendChanged and marketTrend == 1
    strategy.entry("Long Trend", strategy.long, qty=positionSizeScript1)
    longEntryPrice := close
    
if trendChanged and marketTrend == -1
    strategy.entry("Short Trend", strategy.short, qty=positionSizeScript1)
    shortEntryPrice := close

if longSignal and strategy.position_size == 0
    strategy.entry("Long Signal", strategy.long, qty=positionSizeScript2)
    longEntryPrice := close
    
if shortSignal and strategy.position_size == 0
    strategy.entry("Short Signal", strategy.short, qty=positionSizeScript2)
    shortEntryPrice := close