모멘텀 추적 적응 통계적 중재 전략

저자:차오장, 날짜: 2023-12-11 16:41:27
태그:

img

전반적인 설명

이 전략은 Nadaraya-Watson 커널 회귀 방법을 기반으로 동적 변동성 봉투를 구축하여 가격과 봉투 대역 사이의 교차 상황을 추적하여 낮은 가격과 높은 판매를 구매하는 거래 신호를 생성합니다. 수학적 분석 프레임워크로 전략은 시장 변화에 적응 할 수 있습니다.

전략 논리

이 전략의 핵심은 가격의 동적 봉투를 계산하는 것입니다. 첫째, 사용자 지정 룩백 창을 사용하여, 그것은 평탄한 가격 추정치를 얻기 위해 가격의 나다라야-왓슨 커널 회귀 곡선을 구축합니다. 그 다음에는 사용자 지정 ATR 길이를 기반으로 ATR을 계산하고, 가까운 및 먼 인자로 상위 및 하위 봉투 대역을 형성합니다. 가격이 아래에서 봉투로 넘어가면 구매 신호가 생성됩니다. 가격이 위에서 봉투에서 넘어가면 판매 신호가 유발됩니다. 가격과 변동성 관련 통계 특성의 역학적 관계를 추적함으로써 전략은 적응적으로 거래 결정을 조정합니다.

장점

  1. 제어 가능한 매개 변수를 가진 수학적 모델에 기초하여, 과장 장착의 확률이 낮습니다.
  2. 가격과 변동성 사이의 역동적인 관계를 활용하여 거래 기회를 잡기 위해 시장 변화에 적응합니다.
  3. 로그 스케일은 다양한 시간 프레임과 변동성 크기가 다른 기기와 잘 작동합니다.
  4. 전략 감수성을 조정할 수 있는 매개 변수

위험성

  1. 수학 모델의 이론적 특성상 라이브 거래에서 실적이 떨어질 수 있습니다.
  2. 주요 매개 변수들은 전문적인 지식을 필요로 합니다. 잘못된 설정은 수익성을 손상시킬 수 있습니다.
  3. 문제가 늦어지면 거래 기회를 놓칠 수 있습니다.
  4. 매우 변동적인 시장에서 휘파람에 취약합니다.

적절한 최적화, 충분한 백테스트, 핵심 요소에 대한 이해 및 실시간 거래에서 신중한 포지션 크기는 이러한 위험을 완화하는 데 도움이 될 수 있습니다.

개선 방향

  1. 최적의 조합을 찾기 위해 매개 변수를 더 최적화합니다.
  2. 기계 학습 방법을 적용하여 최적의 매개 변수를 자동으로 선택합니다.
  3. 특정 시장 환경에서 전략을 활성화하기 위해 필터를 추가합니다.
  4. 잘못된 신호를 필터링하기 위해 다른 지표를 포함합니다.
  5. 다른 수학 모델 알고리즘을 시도해보세요.

결론

이 전략은 가격과 변동성 사이의 관계를 동적으로 추적하여 거래 신호를 생성하기 위해 통계 분석과 기술 지표 분석을 통합합니다. 시장 조건과 개인적인 필요에 따라 매개 변수를 조정할 수 있습니다. 전반적으로, 탄탄한 이론적 기초에도 불구하고 실제 성능은 여전히 추가 검증이 필요합니다. 신중하게 취급하고 신중하게 거래해야합니다.


/*backtest
start: 2022-12-04 00:00:00
end: 2023-12-10 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// © Julien_Eche
//@version=5

strategy("Nadaraya-Watson Envelope Strategy", overlay=true, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=20)

// Helper Functions
getEnvelopeBounds(_atr, _nearFactor, _farFactor, _envelope) => 
    _upperFar = _envelope + _farFactor*_atr
    _upperNear = _envelope + _nearFactor*_atr
    _lowerNear = _envelope - _nearFactor*_atr
    _lowerFar = _envelope - _farFactor*_atr
    _upperAvg = (_upperFar + _upperNear) / 2
    _lowerAvg = (_lowerFar + _lowerNear) / 2 
    [_upperNear, _upperFar, _upperAvg, _lowerNear, _lowerFar, _lowerAvg]

customATR(length, _high, _low, _close) =>
    trueRange = na(_high[1])? math.log(_high)-math.log(_low) : math.max(math.max(math.log(_high) - math.log(_low), math.abs(math.log(_high) - math.log(_close[1]))), math.abs(math.log(_low) - math.log(_close[1])))
    ta.rma(trueRange, length)

customKernel(x, h, alpha, x_0) =>
    sumWeights = 0.0
    sumXWeights = 0.0
    for i = 0 to h
        weight = math.pow(1 + (math.pow((x_0 - i), 2) / (2 * alpha * h * h)), -alpha)
        sumWeights := sumWeights + weight
        sumXWeights := sumXWeights + weight * x[i]
    sumXWeights / sumWeights

// Custom Settings
customLookbackWindow = input.int(8, 'Lookback Window (Custom)', group='Custom Settings')
customRelativeWeighting = input.float(8., 'Relative Weighting (Custom)', step=0.25, group='Custom Settings')
customStartRegressionBar = input.int(25, "Start Regression at Bar (Custom)", group='Custom Settings')

// Envelope Calculations
customEnvelopeClose = math.exp(customKernel(math.log(close), customLookbackWindow, customRelativeWeighting, customStartRegressionBar))
customEnvelopeHigh = math.exp(customKernel(math.log(high), customLookbackWindow, customRelativeWeighting, customStartRegressionBar))
customEnvelopeLow = math.exp(customKernel(math.log(low), customLookbackWindow, customRelativeWeighting, customStartRegressionBar))
customEnvelope = customEnvelopeClose
customATRLength = input.int(60, 'ATR Length (Custom)', minval=1, group='Custom Settings')
customATR = customATR(customATRLength, customEnvelopeHigh, customEnvelopeLow, customEnvelopeClose)
customNearATRFactor = input.float(1.5, 'Near ATR Factor (Custom)', minval=0.5, step=0.25, group='Custom Settings')
customFarATRFactor = input.float(2.0, 'Far ATR Factor (Custom)', minval=1.0, step=0.25, group='Custom Settings')
[customUpperNear, customUpperFar, customUpperAvg, customLowerNear, customLowerFar, customLowerAvg] = getEnvelopeBounds(customATR, customNearATRFactor, customFarATRFactor, math.log(customEnvelopeClose))

// Colors
customUpperBoundaryColorFar = color.new(color.red, 60)
customUpperBoundaryColorNear = color.new(color.red, 80)
customBullishEstimatorColor = color.new(color.teal, 50)
customBearishEstimatorColor = color.new(color.red, 50)
customLowerBoundaryColorNear = color.new(color.teal, 80)
customLowerBoundaryColorFar = color.new(color.teal, 60)

// Plots
customUpperBoundaryFar = plot(math.exp(customUpperFar), color=customUpperBoundaryColorFar, title='Upper Boundary: Far (Custom)')
customUpperBoundaryAvg = plot(math.exp(customUpperAvg), color=customUpperBoundaryColorNear, title='Upper Boundary: Average (Custom)')
customUpperBoundaryNear = plot(math.exp(customUpperNear), color=customUpperBoundaryColorNear, title='Upper Boundary: Near (Custom)') 
customEstimationPlot = plot(customEnvelopeClose, color=customEnvelope > customEnvelope[1] ? customBullishEstimatorColor : customBearishEstimatorColor, linewidth=2, title='Custom Estimation')
customLowerBoundaryNear = plot(math.exp(customLowerNear), color=customLowerBoundaryColorNear, title='Lower Boundary: Near (Custom)')
customLowerBoundaryAvg = plot(math.exp(customLowerAvg), color=customLowerBoundaryColorNear, title='Lower Boundary: Average (Custom)') 
customLowerBoundaryFar = plot(math.exp(customLowerFar), color=customLowerBoundaryColorFar, title='Lower Boundary: Far (Custom)')

// Fills
fill(customUpperBoundaryFar, customUpperBoundaryAvg, color=customUpperBoundaryColorFar, title='Upper Boundary: Farmost Region (Custom)')
fill(customUpperBoundaryNear, customUpperBoundaryAvg, color=customUpperBoundaryColorNear, title='Upper Boundary: Nearmost Region (Custom)')
fill(customLowerBoundaryNear, customLowerBoundaryAvg, color=customLowerBoundaryColorNear, title='Lower Boundary: Nearmost Region (Custom)')
fill(customLowerBoundaryFar, customLowerBoundaryAvg, color=customLowerBoundaryColorFar, title='Lower Boundary: Farmost Region (Custom)')


longCondition = ta.crossover(close, customEnvelopeLow)
if (longCondition)
    strategy.entry("Buy", strategy.long)

exitLongCondition = ta.crossover(customEnvelopeHigh, close)
if (exitLongCondition)
    strategy.close("Buy")


더 많은