역사적 델타 SMA 최고치 및 최저치를 기반으로 한 거래 추세 포착 전략

SMA DELTA MA
생성 날짜: 2025-02-19 10:47:50 마지막으로 수정됨: 2025-02-19 10:47:50
복사: 3 클릭수: 350
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

역사적 델타 SMA 최고치 및 최저치를 기반으로 한 거래 추세 포착 전략

개요

이것은 매매량 델타값의 SMA (Simple Moving Average) 를 기반으로 한 한 해 동안의 높은 낮은 점 분석을 하는 거래 전략이다. 이 전략은 매매량 차이의 이동 평균을 계산하고 그것을 역사적인 높은 낮은 점과 비교하여 잠재적인 거래 신호를 식별한다. 이 전략은 긴 회귀기를 채택하여 중장기 트렌드 거래에 적합하다.

전략 원칙

전략의 핵심 논리는 다음과 같은 핵심 단계에 기초합니다.

  1. 델타 계산: 가격 움직임을 분석하여 매매량 차이를 계산한다. 상장 가격이 상장 가격보다 높을 때 매매량으로 기록되며, 반대로 매매량으로 기록된다.
  2. SMA 부드러운 처리: 델타 값을 14주기 이동 평균 처리하여 소음을 줄인다.
  3. 1년 동안의 최고와 최저치를 결정합니다. 지난 1년 동안의 최고와 최저값을 계산합니다.
  4. 신호 발사 조건:
    • 구매 신호: 델타 SMA가 1년 하위 70% 이후 0을 돌파할 때 트리거
    • 팔기 신호: 델타 SMA가 1년 초반의 90%를 넘어서 60%를 넘으면 발동됩니다.

전략적 이점

  1. 장기적인 트렌드를 파악하는 능력: 1년 동안의 역사적인 데이터 분석을 통해 주요 트렌드를 효과적으로 파악할 수 있다.
  2. 노이즈 필터링 효과: SMA 부드러운 처리와 여러 값 조건을 사용하여 가짜 신호를 효과적으로 감소시킨다.
  3. 위험 통제는 합리적입니다: 명확한 입출장 조건이 설정되어 과도한 거래를 방지합니다.
  4. 적응력: 전략의 매개 변수는 시장의 다른 조건에 따라 조정될 수 있다.

전략적 위험

  1. 지연 위험: SMA와 장기 회귀 기간의 사용으로 인해 신호 지연이 발생할 수 있다.
  2. 가짜 돌파 위험: 불안한 시장에서 잘못된 신호가 발생할 수 있습니다.
  3. 시장 환경 의존성: 추세가 보이지 않는 시장에서 좋지 않은 성과를 낼 수 있다.
  4. 매개 변수 민감성: 미지수 설정은 전략 성능에 큰 영향을 미칩니다.

전략 최적화 방향

  1. 동적 하락 조정: 시장의 변동성 동적에 따라 고저점 하락 조정할 수 있다.
  2. 보조 지표를 추가: 다른 기술 지표와 결합하여 신호 신뢰성을 향상한다.
  3. 스톱 메커니즘을 도입: 위험을 제어하기 위해 동적 스톱을 설정한다.
  4. 시장 환경 필터링: 시장 환경 판단 논리를 추가하여 적절한 환경에서 전략을 실행합니다.

요약하다

이것은 거래량 분석을 기반으로 한 중장기 트렌드 추적 전략으로, 거래량 차이의 역사적 높고 낮은 점을 분석하여 시장 추세를 포착합니다. 전략은 합리적으로 설계되어 있으며 위험을 통제하지만 시장 환경의 적응성과 파라미터 최적화 문제를 주의해야합니다. 제안 된 최적화 방향으로 전략은 더 향상 될 여지가 있습니다.

전략 소스 코드
/*backtest
start: 2024-02-20 00:00:00
end: 2025-02-17 08:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Delta SMA 1-Year High/Low Strategy", overlay = false, margin_long = 100, margin_short = 100)

// Inputs
delta_sma_length = input.int(14, title="Delta SMA Length", minval=1)  // SMA length for Delta
lookback_days = 365  // Lookback period fixed to 1 year

// Function to calculate buy and sell volume
buy_volume = close > open ? volume : na
sell_volume = close < open ? volume : na

// Calculate the Delta
delta = nz(buy_volume, 0) - nz(sell_volume, 0)

// Calculate Delta SMA
delta_sma = ta.sma(delta, delta_sma_length)

// Lookback period in bars (1 bar = 1 day)
desired_lookback_bars = lookback_days

// Ensure lookback doesn't exceed available historical data
max_lookback_bars = math.min(desired_lookback_bars, 365)  // Cap at 365 bars (1 year)

// Calculate Delta SMA low and high within the valid lookback period
delta_sma_low_1yr = ta.lowest(delta_sma, max_lookback_bars)
delta_sma_high_1yr = ta.highest(delta_sma, max_lookback_bars)

// Define thresholds for buy and sell conditions
very_low_threshold = delta_sma_low_1yr * 0.7
above_70_threshold = delta_sma_high_1yr * 0.9
below_60_threshold = delta_sma_high_1yr * 0.5

// Track if `delta_sma` was very low and persist the state
var bool was_very_low = false
if delta_sma < very_low_threshold
    was_very_low := true
if ta.crossover(delta_sma, 10000)
    was_very_low := false  // Reset after crossing 0

// Track if `delta_sma` crossed above 70% of the high
var bool crossed_above_70 = false
if ta.crossover(delta_sma, above_70_threshold)
    crossed_above_70 := true
if delta_sma < below_60_threshold*0.5 and crossed_above_70
    crossed_above_70 := false  // Reset after triggering sell

// Buy condition: `delta_sma` was very low and now crosses 0
buy_condition = was_very_low and ta.crossover(delta_sma, 0)

// Sell condition: `delta_sma` crossed above 70% of the high and now drops below 60%
sell_condition = crossed_above_70 and delta_sma < below_60_threshold

// Place a long order when buy condition is met
if buy_condition
    strategy.entry("Buy", strategy.long)

// Place a short order when sell condition is met
if sell_condition
    strategy.close("Buy")

// Plot Delta SMA and thresholds for visualization
plot(delta_sma, color=color.blue, title="Delta SMA")
plot(very_low_threshold, color=color.green, title="70% of 1-Year Delta SMA Low", linewidth=2)
plot(above_70_threshold, color=color.purple, title="70% of 1-Year Delta SMA High", linewidth=2)
plot(below_60_threshold, color=color.red, title="60% of 1-Year Delta SMA High", linewidth=2)

// Optional: Plot Buy and Sell signals on the chart
//plotshape(series=buy_condition, title="Buy Signal", location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="BUY")
//plotshape(series=sell_condition, title="Sell Signal", location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="SELL")