트렌드 추적 그리드 동적 위치 조정 정량적 전략

TTM EMA GRID DCA ATR SMA
생성 날짜: 2024-12-12 11:19:17 마지막으로 수정됨: 2024-12-12 11:19:17
복사: 0 클릭수: 641
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

트렌드 추적 그리드 동적 위치 조정 정량적 전략

개요

이 전략은 TTM 지표에 기반한 동적 격자 거래 시스템으로, 높은 낮은 지수 이동 평균 (EMA) 의 계산을 통해 시장의 경향 방향을 판단하고, 동적으로 업데이트 된 기준 가격을 중심으로 격자 거래 시스템을 배포한다. 격자의 방향과 가격 수준은 동적으로 트렌드에 따라 조정되며, 가격이 미리 정의된 격자 수준을 넘어서면 거래가 수행되며, 각 거래의 리스크 은 계좌 권익에 대한 고정된 비율이다.

전략 원칙

이 전략의 핵심 논리는 TTM 상태 계산에 있다.

  1. ttmPeriod 변수를 기반으로 두 개의 EMA를 계산합니다: 낮은 지점 EMA ((lowMA) 와 높은 지점 EMA ((highMA)
  2. highMA와 lowMA 사이에 두 개의 절댓값 레벨을 정의한다:
    • lowThird: 아래 13 위치
    • highThird: 아래 23 위치
  3. 종전 가격의 위치와 관련한 TTM 상태를 결정한다:
    • 마감가격이 highThird보다 높을 때, 1 (상향) 로 돌아갑니다
    • 마감 가격이 lowThird보다 낮으면 0으로 돌아갑니다.
    • 마감값이 lowThird와 highThird 사이에 있을 때, -1 (중립 상태) 로 돌아갑니다.

그리드 거래 시스템은 TTM 상태에 따라 동적으로 조정됩니다:

  1. TTM 상태가 변경되면 그리드 기준 가격과 방향을 업데이트합니다.
  2. 그리드 방향과 간격에 따라 구매 가격 수준을 계산합니다.
  3. 가격의 격자 레벨을 돌파할 때 해당 구매 또는 판매 작업을 수행

전략적 이점

  1. 동적 적응력: 전략은 시장 추세에 따라 격자 방향과 가격 수준을 동적으로 조정할 수 있으며, 전략의 적응력과 수익성을 향상시킵니다.
  2. 리스크 제어: 고정된 비율을 사용하여 포지션 관리를 수행하여 각 거래의 리스크 을 효과적으로 제어합니다.
  3. 매개 변수 조정 가능: TTM 주기, 격자 레벨 및 간격과 같은 핵심 매개 변수는 시장 상황에 따라 최적화 할 수 있습니다.
  4. 실행 메커니즘이 명확하다: 거래 신호가 명확하고, 실행 논리는 간단하고 직관적이며, 재검토 및 실 디스크 동작이 용이하다

전략적 위험

  1. 트렌드 판단 지연: EMA 기반의 TTM 지표에 약간의 지연이 존재하여 트렌드 전환점의 신호 지연이 발생할 수 있습니다.
  2. 흔들림 시장 위험: 가로판 흔들림 시장에서, 격자 방향의 빈번한 전환은 과도한 거래와 수수료 손실을 초래할 수 있습니다.
  3. 재무 관리 압력: 여러 네트워크가 동시에 운영되는 경우 대규모 자금이 필요하며, 전략의 실무 가능성에 영향을 미칠 수 있습니다.
  4. 슬라이드 포인트 영향: 유동성이 부족할 때 HFG 거래는 전략 성과에 영향을 미치는 큰 슬라이드 포인트에 직면 할 수 있습니다.

전략 최적화 방향

  1. 트렌드 판단 최적화:
    • 트렌드 판단의 정확성을 높이기 위해 다중 시간 주기의 분석을 도입합니다.
    • RSI, MACD와 같은 다른 기술 지표와 함께 트렌드 확인
  2. 그리드 변수 최적화:
    • 격자 간격이 변동율에 따라 동적으로 조정됩니다.
    • 적응형 격자 레벨 조정 메커니즘을 도입
  3. 자금 관리 개선:
    • 역동적인 포지션 분배
    • 위험 평준화 제도를 강화하는 것
  4. 실행 메커니즘의 개선:
    • 손해 방지 및 정지 장치를 추가
    • 주문 실행 타이밍 최적화

요약하다

이 전략은 TTM 트렌드 판단과 동적 격자 거래를 결합하여, 자기 적응력이 강한, 위험 제어 가능한 거래 시스템을 구현한다. 격자 방향과 가격 수준을 동적으로 조정함으로써, 전략은 다양한 시장 환경에 더 잘 적응할 수 있다. 일부 고유한 위험이 있지만, 합리적인 매개 변수 설정과 최적화 조치를 통해 전략은 좋은 실용적 가치와 발전 잠재력을 가지고 있다.

전략 소스 코드
/*backtest
start: 2024-12-04 00:00:00
end: 2024-12-11 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("TTM Grid Strategy", overlay=true)

// Input parameters
int ttmPeriod = input.int(6, minval=1, title="TTM Period")
int gridLevels = input.int(5, minval=2, title="Grid Levels")
float gridSpacing = input.float(0.01, minval=0.0001, title="Grid Spacing (%)")

// Calculate TTM State
ttmState() =>
    lowMA = ta.ema(low, ttmPeriod)
    highMA = ta.ema(high, ttmPeriod)
    lowThird = (highMA - lowMA) / 3 + lowMA
    highThird = 2 * (highMA - lowMA) / 3 + lowMA

    if close > highThird
        1
    else if close < lowThird
        0
    else
        -1

// State tracking variables
var float gridBasePrice = 0.0
var int gridDirection = -1

// Determine grid state
updateGridState(float currentClose, int currentState) =>
    float newBasePrice = gridBasePrice
    int newDirection = gridDirection

    if currentState != -1 and currentState != gridDirection
        newBasePrice := currentClose
        newDirection := currentState
    
    [newBasePrice, newDirection]

// Calculate grid levels
calcGridLevels(float basePrice, int direction, int levels) =>
    float[] buyLevels = array.new_float(levels)
    float[] sellLevels = array.new_float(levels)

    for i = 1 to levels
        multiplier = i * gridSpacing
        if direction == 1  // Buy grid
            array.set(buyLevels, i-1, basePrice * (1 - multiplier))
            array.set(sellLevels, i-1, basePrice * (1 + multiplier))
        else  // Sell grid
            array.set(buyLevels, i-1, basePrice * (1 + multiplier))
            array.set(sellLevels, i-1, basePrice * (1 - multiplier))
    
    [buyLevels, sellLevels]

// Execute grid trades
executeGridTrades(float basePrice, int direction, int levels) =>
    [buyLevels, sellLevels] = calcGridLevels(basePrice, direction, levels)

    for i = 0 to levels - 1
        float buyLevel = array.get(buyLevels, i)
        float sellLevel = array.get(sellLevels, i)

        if direction == 1  // Buy grid
            if low <= buyLevel
                strategy.entry("GridBuy" + str.tostring(i), strategy.long, comment="Buy Level " + str.tostring(i))
            if high >= sellLevel
                strategy.entry("GridSell" + str.tostring(i), strategy.short, comment="Sell Level " + str.tostring(i))
        else  // Sell grid
            if high >= buyLevel
                strategy.entry("GridBuy" + str.tostring(i), strategy.long, comment="Buy Level " + str.tostring(i))
            if low <= sellLevel
                strategy.entry("GridSell" + str.tostring(i), strategy.short, comment="Sell Level " + str.tostring(i))

// Main strategy logic
currentState = ttmState()
[newGridBasePrice, newGridDirection] = updateGridState(close, currentState)

// Update global variables
if newGridBasePrice != gridBasePrice
    gridBasePrice := newGridBasePrice
if newGridDirection != gridDirection
    gridDirection := newGridDirection

// Execute grid trades
executeGridTrades(newGridBasePrice, newGridDirection, gridLevels)

// Visualization
plotColor = newGridDirection == 1 ? color.green : color.red
plot(newGridBasePrice, color=plotColor, style=plot.style_cross)