양적 롱 앤 숏 추세 추적 동적 손절매 전략

ATR EMA CROSSOVER DYNAMIC STOP-LOSS
생성 날짜: 2025-04-03 11:34:48 마지막으로 수정됨: 2025-04-03 11:34:48
복사: 0 클릭수: 447
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

양적 롱 앤 숏 추세 추적 동적 손절매 전략 양적 롱 앤 숏 추세 추적 동적 손절매 전략

개요

이것은 평균 실제 변동 범위 ((ATR) 와 지수 이동 평균 ((EMA) 를 기반으로 한 다중 공간 트렌드 추적 전략이다. 전략은 동적 스톱로스 및 트렌드 판단을 통해 시장 추세를 정확하게 포착하고 위험을 관리합니다.

전략 원칙

전략의 핵심은 다음과 같은 핵심 단계입니다.

  1. ATR 지수를 사용하여 동적 스톱포인트를 계산합니다.
  2. 가격 추세 방향에 대한 EMA 판단과 함께
  3. 가격과 스톱포드의 상대적인 위치를 통해 거래 신호를 결정합니다.
  4. 하이킨 아시 (Heikin Ashi) 도면을 사용하여 선택적으로 최적화된 신호 식별

컴퓨터 논리:

  • 동적 정지점 = 현재 가격 ± (ATR * 감수성 계수)
  • EMA와 정지점의 교차를 기반으로 트렌드를 판단합니다.
  • 거래 신호는 가격이 스톱로스를 돌파하고 EMA를 넘어서면 생성됩니다.

전략적 이점

  1. 동적 리스크 관리: ATR은 시장의 변동성에 따라 실시간으로 조정되는 스톱로스 계산에 적응합니다.
  2. 트렌드 추적의 정확성: EMA가 가격 변화에 신속하게 반응하여 트렌드 전환점을 포착합니다.
  3. 유연성: ATR 주기 및 민감도 계수를 사용자 정의할 수 있습니다.
  4. 선택 가능한 하이켄 아치 맵, 신호 식별을 더욱 최적화
  5. 낮은 거래 빈도, 낮은 거래 비용
  6. 다 시장, 다 품종

전략적 위험

  1. 시장의 흔들림으로 인해 잘못된 신호가 발생할 수 있습니다.
  2. 잘못된 매개 변수 설정으로 인해 과도한 거래가 발생할 수 있습니다.
  3. 기본적 요소와 갑작스러운 사건의 영향은 고려되지 않았습니다.
  4. 리베이트와 실디의 차이가 있다.

위험 관리 제안:

  • 최적화 매개 변수, 감수성 계수를 낮추기
  • 다른 지표와 결합
  • 스톱로스 및 포지션 관리 설정
  • 지속적인 감시와 동적 조정

전략 최적화 방향

  1. 기계 학습 알고리즘의 동적 최적화 매개 변수를 도입
  2. 다중 시간 주기 검증을 추가합니다.
  3. 다른 기술 지표 포트폴리오와 결합
  4. 적응 변수 선택 메커니즘 개발
  5. 리스크 조정 모듈을 추가

최적화 목표: 전략적 안정성을 높이고, 회수율을 낮추고, 수익성을 높인다.

요약하다

이것은 ATR와 EMA에 기반한 동적 트렌드 추적 전략으로, 유연한 손해 방지 장치와 트렌드 판단을 통해 비교적 안정적인 시장 참여를 달성한다. 전략은 좋은 적응성과 위험 관리 특성을 가지고 있지만, 계속적인 최적화와 검증이 필요하다.

전략 소스 코드
/*backtest
start: 2025-01-01 00:00:00
end: 2025-04-02 00:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BNB_USDT"}]
*/

//@version=6
strategy("ducanhmaster v1", overlay=true, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// Inputs
a = input.int(1, title="Key Value. 'This changes the sensitivity'")
c = input.int(10, title="ATR Period")
h = input.bool(false, title="Signals from Heikin Ashi Candles")

xATR  = ta.atr(c)
nLoss = a * xATR

// Compute Heikin Ashi values
heikinAshiOpen = (open + close) / 2
heikinAshiClose = (open + high + low + close) / 4
heikinAshiHigh = math.max(high, math.max(heikinAshiOpen, heikinAshiClose))
heikinAshiLow = math.min(low, math.min(heikinAshiOpen, heikinAshiClose))

src = h ? heikinAshiClose : close

// Declare xATRTrailingStop as a float variable and initialize it with 'na'
var float xATRTrailingStop = na
if (src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0))
    xATRTrailingStop := math.max(nz(xATRTrailingStop[1]), src - nLoss)
else if (src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0))
    xATRTrailingStop := math.min(nz(xATRTrailingStop[1]), src + nLoss)
else
    xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss

// Declare 'pos' as an integer variable instead of leaving it undefined
var int pos = na
if (src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0))
    pos := 1
else if (src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0))
    pos := -1
else
    pos := nz(pos[1], 0)

xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue

ema = ta.ema(src, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)

buy  = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below

barbuy  = src > xATRTrailingStop
barsell = src < xATRTrailingStop

// Plot buy/sell signals on the chart
plotshape(buy, title="Buy", text='Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.white, size=size.tiny)
plotshape(sell, title="Sell", text='Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.white, size=size.tiny)

// Change bar color when buy/sell conditions are met
barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)

// Enter a Long trade when a buy signal appears and exit when a sell signal appears
if (buy)
    strategy.entry("long", strategy.long)

if (sell)
    strategy.close("long")