최적화된 평균 참 범위 기반 추세 전략 v6(고정 추세 포착)

ATR EMA SMMA RSI TSL
생성 날짜: 2025-03-31 16:50:30 마지막으로 수정됨: 2025-03-31 16:50:41
복사: 0 클릭수: 417
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

최적화된 평균 참 범위 기반 추세 전략 v6(고정 추세 포착) 최적화된 평균 참 범위 기반 추세 전략 v6(고정 추세 포착)

개요

이 전략은 ATR 필터링, 슈퍼 트렌드 지표, 지수 이동 평균 (EMA) 및 간단한 이동 평균 (SMMA) 트렌드 밴드, 상대적으로 강한 지수 (RSI) 확인 및 동적 스톱 시스템을 통합하여 포괄적이고 유연한 거래 방법을 제공합니다.

전략 원칙

이 전략의 핵심은 여러 기술 지표의 상호 작용에 기초하고 있습니다.

  1. 트렌드 식별: 슈퍼 트렌드 지표 ((변수: 인수 2, 길이 5) 와 50 일 EMA와 8 일 SMMA 트렌드를 사용하여 시장 트렌드 방향을 정의하십시오. 트렌드는 색으로 코딩됩니다.

    • 녹색: 오징어 추세
    • 빨간색: 하향
    • 회색: 중성 단계
  2. ATR 스마트 필터: 14주기 ATR과 50주기 SIMA를 통해 변동성 확장을 감지하고, ATR이 상승하거나 SMA의 101% 이상일 때만 거래하여 강세를 보이는 경우에만 입장을 보장합니다.

  3. 입장 조건:

    • 더 많은 진입: 50 일 EMA보다 높은 가격, 슈퍼 트렌드 시세, RSI > 45, ATR 트렌드 강도를 확인
    • 상장: 50일 EMA 이하의 가격, 수퍼 트렌드 하향, RSI < 45, ATR 트렌드 강도를 확인
  4. 역동적인 정지 및 정지:

    • 정지: 5배의 ATR에 기반한 적응 정지
    • 추적 손실: 3.5배 ATR
    • 상장 손실: ATR의 2배 이동 후 시작
    • 고정 스톱: 0.8배의 ATR 배수를 사용하여 위험 관리

전략적 이점

  1. 낮은 변동성 지역에서 거래하는 것을 피하기 위해 변동성 시장을 효과적으로 필터링하십시오.
  2. 과도한 거래를 방지하고, 조기 재출입을 방지하기 위한 차단 잠금 장치
  3. 강력한 트렌드를 포착하고 손실을 추적하여 수익을 유지합니다.
  4. ATR의 기본 상쇄는 큰 손실을 방지합니다.
  5. 매개 변수 조정 가능, 다른 시장에 미세 조정 ATR 곱하기, 중지, 중지 및 RSI 필터

전략적 위험

  1. 기술 지표에 지나치게 의존하면 잘못된 신호가 발생할 수 있습니다.
  2. 시장의 흔들림 속에서 부진할 수도 있다.
  3. 잘못된 매개 변수 설정으로 거래 비용이 증가할 수 있습니다.
  4. RSI는 빠른 트렌드 변화를 놓쳤을 수 있음을 확인합니다.

전략 최적화 방향

  1. 기계 학습 알고리즘을 도입하고, 동적으로 변수를 조정합니다.
  2. 추가 필터를 추가합니다.
  3. 다양한 시장과 시간 프레임에 대한 최적의 요소 조합을 탐구합니다.
  4. 다중 시간 프레임 검증 메커니즘 개발

요약하다

이것은 고급 트렌드 추적 전략으로, 다중 지표 협동 및 동적 위험 관리를 통해 거래자에게 유연하고 강력한 거래 도구를 제공합니다. 지속적인 피드백과 최적화는이 전략을 성공적으로 적용하는 데 중요합니다.

전략 소스 코드
/*backtest
start: 2024-03-31 00:00:00
end: 2025-03-29 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/

//@version=6
strategy("Optimized ATR-Based Trend Strategy v6 (Fixed Trend Capture)", overlay=true)

// 🔹 Input parameters
lengthSMMA = input(8, title="SMMA Length")
lengthEMA = input(50, title="EMA Length")
supertrendFactor = input(2.0, title="Supertrend Factor")
supertrendLength = input(5, title="Supertrend Length")
atrLength = input(14, title="ATR Length")  
atrSmoothing = input(50, title="ATR Moving Average Length")  
atrMultiplierTP = input.float(5.0, title="ATR Multiplier for Take-Profit", minval=1.0, step=0.5)  
atrMultiplierTSL = input.float(3.5, title="ATR Multiplier for Trailing Stop-Loss", minval=1.0, step=0.5)  // 🔹 Increased to ride trends
atrStopMultiplier = input.float(0.8, title="ATR Stop Multiplier", minval=0.5, step=0.1)  
breakEvenMultiplier = input.float(2.0, title="Break-Even Trigger ATR Multiplier", minval=1.0, step=0.1)
rsiLength = input(14, title="RSI Length")  

// 🔹 Indicator calculations
smma8 = ta.sma(ta.sma(close, lengthSMMA), lengthSMMA)  
ema50 = ta.ema(close, lengthEMA)  

// 🔹 Supertrend Calculation
[superTrend, _] = ta.supertrend(supertrendFactor, supertrendLength)

// 🔹 Supertrend Conditions
isBullishSupertrend = close > superTrend
isBearishSupertrend = close < superTrend

// 🔹 ATR Calculation for Smarter Filtering
atrValue = ta.atr(atrLength)
atrMA = ta.sma(atrValue, atrSmoothing)
atrRising = ta.rising(atrValue, 3)  // 🔹 More sensitive ATR detection
isTrending = atrValue > atrMA * 1.01 or atrRising  // 🔹 Loosened ATR filter

// 🔹 RSI Calculation
rsi = ta.rsi(close, rsiLength)

// 🔹 RSI Conditions (More Flexible)
isRSIBullish = rsi > 45  // 🔹 Lowered to capture early trends
isRSIBearish = rsi < 45  

// 🔹 TP Lock Mechanism
var bool tpHit = false  
if strategy.position_size == 0 and strategy.closedtrades > 0
    tpHit := true  

// 🔹 Supertrend Flip Detection (Resumes Trading After Trend Change)
trendFlip = (isBullishSupertrend and not isBullishSupertrend[1]) or (isBearishSupertrend and not isBearishSupertrend[1])
if trendFlip
    tpHit := false  

// 🔹 Entry Conditions
bullishEntry = close > ema50 and isBullishSupertrend and isRSIBullish and isTrending and not tpHit
bearishEntry = close < ema50 and isBearishSupertrend and isRSIBearish and isTrending and not tpHit

// 🔹 Dynamic Take-Profit, Stop-Loss, and Break-Even Stop
longTakeProfit = close + (atrValue * atrMultiplierTP)  
shortTakeProfit = close - (atrValue * atrMultiplierTP)  
longTrailStop = atrValue * atrMultiplierTSL  
shortTrailStop = atrValue * atrMultiplierTSL  

// ✅ Adjusted SL to Reduce Drawdown
longStopLoss = close - (atrValue * atrMultiplierTSL * atrStopMultiplier)
shortStopLoss = close + (atrValue * atrMultiplierTSL * atrStopMultiplier)

// ✅ Break-Even Stop Trigger (More Room for Trends)
longBreakEven = strategy.position_avg_price + (atrValue * breakEvenMultiplier)
shortBreakEven = strategy.position_avg_price - (atrValue * breakEvenMultiplier)

// 🔹 Strategy Execution (Fixed Take-Profit & Stop-Loss)
if (bullishEntry)
    strategy.entry("Buy", strategy.long)
    strategy.exit("TSL/TP", from_entry="Buy", stop=longStopLoss, trail_offset=longTrailStop, limit=longTakeProfit)
    strategy.exit("BreakEven", from_entry="Buy", stop=longBreakEven)

if (bearishEntry)
    strategy.entry("Sell", strategy.short)
    strategy.exit("TSL/TP", from_entry="Sell", stop=shortStopLoss, trail_offset=shortTrailStop, limit=shortTakeProfit)
    strategy.exit("BreakEven", from_entry="Sell", stop=shortBreakEven)

// 🔹 Trend Band
trendColor = isBullishSupertrend and smma8 > ema50 and close > ema50 ? color.green :
             isBearishSupertrend and smma8 < ema50 and close < ema50 ? color.red : color.gray
fill(plot(smma8, color=color.new(trendColor, 60), title="8 SMMA Band"),
     plot(ema50, color=color.new(trendColor, 60), title="50 EMA Band"),
     color=color.new(trendColor, 80), title="Trend Band")

// 🔹 Supertrend Line
plot(superTrend, color=color.gray, title="Supertrend", style=plot.style_line)