モメントトラッキング アダプティブ統計仲裁戦略

作者: リン・ハーンチャオチャン, 日付: 2023年12月11日 16:41:27
タグ:

img

概要

この戦略は,価格と封筒帯間のクロスオーバー状況を追跡することによって低値で低値で高値で販売する取引信号を生成するために,ナダラヤ-ワトソンカーネル回帰方法に基づく動的変動性エンベロープを構築する.数学的分析フレームワークを使用して,戦略は市場変化に適応することができます.

戦略の論理

この戦略の核心は,価格のダイナミックエンベロープを計算することである.まず,カスタムバックウィンドウを使用して,価格のナダラヤ-ワトソンカーネル回帰曲線 (近,高,低) を構築し,平滑な価格推定を得ます.その後,カスタム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")


もっと