ATR 동적 트레일링 스톱 로스를 갖춘 추세 추종 거래 시스템

ATR EMA ROI TSL
생성 날짜: 2025-02-20 13:22:24 마지막으로 수정됨: 2025-02-20 14:53:21
복사: 2 클릭수: 445
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

ATR 동적 트레일링 스톱 로스를 갖춘 추세 추종 거래 시스템 ATR 동적 트레일링 스톱 로스를 갖춘 추세 추종 거래 시스템

개요

이 전략은 ATR (평균 실제 파장) 에 기반한 동적으로 손실을 추적하는 트렌드 추적 시스템이다. 그것은 EMA 평선을 트렌드 필터로 결합하고, 민감도 파라미터와 ATR 주기를 조정하여 신호의 생성을 제어한다. 시스템은 더 많은 것을 지원할 뿐만 아니라 적자를 지원하며, 완벽한 수익 관리 메커니즘을 가지고 있다.

전략 원칙

  1. ATR 지표를 사용하여 가격 변동의 폭을 계산하고 설정된 감수성 계수 (Key Value) 에 따라 트래킹 중지 거리를 결정합니다.
  2. EMA 평균선을 통해 시장의 경향 방향을 판단하여, 평균선 위에 있는 가격에서만 더 많은 주문을 열고, 평균선 아래에 있는 빈 주문을 열고
  3. 가격이 스톱로스 라인을 뚫고 트렌드 방향에 맞게 거래 신호를 유발합니다.
  4. 이 시스템은 분기 수익을 창출하는 방식으로 포지션을 관리합니다.
    • 이윤이 20%~50%가 되면, 손해배상액을 비용보장액으로 올릴 수 있다.
    • 이윤이 50%-80%가 되면, 일부 이윤이 종료되고, 중지 손실이 강화됩니다.
    • 이윤이 80%-100%인 경우, 영업이익을 보호하기 위한 스톱로스를 더욱 강화합니다.
    • 이윤이 100%를 넘으면 모든 매출이 매진됩니다.

전략적 이점

  1. 동적 추적 스톱은 유행을 효과적으로 추적하고 수익을 보호하면서 조기 퇴출하지 않습니다.
  2. EMA 트렌드 필터링은 가짜 브레이크의 위험을 효과적으로 감소시킵니다.
  3. 분기 수익 메커니즘은 수익을 보장하고 트렌드에 충분한 공간을 제공합니다.
  4. 시장의 기회를 최대한 활용할 수 있도록 더 많은 포커스 거래를 지원합니다.
  5. 다양한 시장 환경에 적응할 수 있는 변수

전략적 위험

  1. 불안한 시장에서 자주 거래하는 것이 손실로 이어질 수 있습니다.
  2. 트렌드 반전의 초기에는 큰 회전이 발생할 수 있습니다.
  3. 잘못된 매개변수 설정은 전략 성능에 영향을 미칠 수 있습니다. 위험 관리 제안:
  • 명확한 트렌드 시장에서 사용하는 것이 좋습니다.
  • 신중하게 선택된 변수, 재검토를 통해 최적화
  • 최대 회수 제한을 설정
  • 시장 환경 필터링 조건을 추가하는 것을 고려하십시오.

전략 최적화 방향

  1. 시장 환경 식별 메커니즘을 추가하여 다른 시장 조건에 따라 다른 매개 변수를 사용하십시오.
  2. 교통량과 같은 보조 지표를 도입하여 신호 신뢰성을 강화
  3. 수익 관리 메커니즘을 최적화하여 수익 목표를 변동률에 따라 조정합니다.
  4. 시간 필터링을 늘리고 불리한 시간에 거래하는 것을 피하십시오.
  5. 과도한 변동성이 있는 경우 거래 빈도를 낮추는 변동성 필터를 추가하는 것을 고려하십시오.

요약하다

이것은 구조적으로 완전하고 논리적으로 명확한 트렌드 추적 시스템이다. ATR 동적 추적과 EMA 트렌드 필터를 결합하여 트렌드를 파악하면서 위험을 더 잘 통제한다. 분기 수익 메커니즘의 설계도 성숙한 거래 사고를 나타냅니다. 전략은 강력한 실용성과 확장성을 가지고 있으며, 지속적인 최적화와 개선으로 더 나은 거래 효과를 얻을 수 있습니다.

전략 소스 코드
/*backtest
start: 2024-10-15 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Enhanced UT Bot with Long & Short Trades", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// Input Parameters
keyvalue = input.float(1.1, title="Key Value (Sensitivity)", step=0.1)
atrperiod = input.int(200, title="ATR Period")
emaPeriod = input.int(50, title="EMA Period")
roi_close = input.float(100, title="Close Trade at ROI (%)", step=1)

// ATR Calculation
src = close
xATR = ta.atr(atrperiod)
nLoss = keyvalue * xATR

// EMA for Trend Filtering
ema = ta.ema(src, emaPeriod)

// Trailing Stop Logic
var float xATRTrailingStop = na
if na(xATRTrailingStop)
    xATRTrailingStop := src - nLoss

if src > nz(xATRTrailingStop[1]) and src[1] > nz(xATRTrailingStop[1])
    xATRTrailingStop := math.max(nz(xATRTrailingStop[1]), src - nLoss)
else if src < nz(xATRTrailingStop[1]) and src[1] < nz(xATRTrailingStop[1])
    xATRTrailingStop := math.min(nz(xATRTrailingStop[1]), src + nLoss)
else
    xATRTrailingStop := src > nz(xATRTrailingStop[1]) ? src - nLoss : src + nLoss

// Buy/Sell Signal with Trend Filter
buySignal = ta.crossover(src, xATRTrailingStop) and src > ema
sellSignal = ta.crossunder(src, xATRTrailingStop) and src < ema

// Strategy Logic: Long Trades
if buySignal and strategy.position_size <= 0
    strategy.entry("Buy", strategy.long)

if sellSignal and strategy.position_size > 0
    strategy.close("Buy")

// Strategy Logic: Short Trades
if sellSignal and strategy.position_size >= 0
    strategy.entry("Sell", strategy.short)

if buySignal and strategy.position_size < 0
    strategy.close("Sell")

// ROI Calculation for Both Long and Short Trades
var float entryPrice = na
var bool isLong = na
if strategy.position_size > 0
    entryPrice := strategy.opentrades.entry_price(0)
    isLong := true
if strategy.position_size < 0
    entryPrice := strategy.opentrades.entry_price(0)
    isLong := false

// Calculate current profit
currentProfit = isLong ? (close - entryPrice) / entryPrice * 100 : (entryPrice - close) / entryPrice * 100

// Enhanced ROI Management
if strategy.position_size > 0 // Long Position
    if currentProfit >= 20 and currentProfit < 50
        stopLevel = entryPrice // Breakeven
        strategy.exit("TSL Breakeven", from_entry="Buy", stop=stopLevel)
    if currentProfit >= 50 and currentProfit < 80
        stopLevel = entryPrice * 1.30 // 30% ROI
        strategy.exit("TSL 30%", from_entry="Buy", stop=stopLevel)
        strategy.close("Partial Profit", qty_percent=50) // Take 50% profit
    if currentProfit >= 80 and currentProfit < roi_close
        stopLevel = entryPrice * 1.60 // 60% ROI
        strategy.exit("TSL 60%", from_entry="Buy", stop=stopLevel)
    if currentProfit >= roi_close
        strategy.close("Full Exit at 100% ROI")

if strategy.position_size < 0 // Short Position
    if currentProfit >= 20 and currentProfit < 50
        stopLevel = entryPrice // Breakeven
        strategy.exit("TSL Breakeven", from_entry="Sell", stop=stopLevel)
    if currentProfit >= 50 and currentProfit < 80
        stopLevel = entryPrice * 0.70 // 30% ROI (Short stop)
        strategy.exit("TSL 30%", from_entry="Sell", stop=stopLevel)
        strategy.close("Partial Profit", qty_percent=50) // Take 50% profit
    if currentProfit >= 80 and currentProfit < roi_close
        stopLevel = entryPrice * 0.40 // 60% ROI (Short stop)
        strategy.exit("TSL 60%", from_entry="Sell", stop=stopLevel)
    if currentProfit >= roi_close
        strategy.close("Full Exit at 100% ROI")

// Plotting
plot(xATRTrailingStop, color=buySignal ? color.green : sellSignal ? color.red : color.gray, title="Trailing Stop")
plot(ema, color=color.blue, title="EMA Trend Filter")
plotshape(buySignal, title="Buy Signal", style=shape.labelup, location=location.belowbar, color=color.green, text="Buy")
plotshape(sellSignal, title="Sell Signal", style=shape.labeldown, location=location.abovebar, color=color.red, text="Sell")