ピボットポイントとフィボナッチリトレースメントに基づく自動トレンド 戦略をフォローする

作者: リン・ハーンチャオチャン,日付: 2024-01-05 11:34:17
タグ:

img

概要

この戦略は,ピボットポイントとフィボナッチリトレースメント比率に基づいて株式価格のABCパターンを自動的に識別し,ロング/ショート信号を生成する.ピボナッチリトレースメント比率を計算し,価格波を決定する.比率が特定の基準を満たす場合は,取引信号が生成される.

戦略の論理

  1. 株式のピボットの高値と低値を計算する
  2. 価格が前回の高値から下がったか,前回の低値から上昇したかを判断します.
  3. 現在の波と前の波の間のフィボナッチリトレースメント比を計算する
  4. 上下の両方の波のリトラセメント比が適切な範囲内であれば,潜在的なABCパターンを決定
  5. ABCパターンの確認後,ポイントCでストップロスを設定し,ポイントAでストップロスを設定します.

利点分析

  1. シグナル精度を向上させるための主要なサポート/レジスタンスレベルをピホットポイントで識別する
  2. フィボナッチリトレースは,ABCパターンを特定することでトレンドターニングポイントを捉える
  3. 明確な利益/損失の規則は 巨大な損失を回避する

リスク分析

  1. ピボットポイントやフィボナッチリトレースは,すべてのトレンドターニングポイントの完璧な識別を保証することはできません.誤った判断が起こる可能性があります.
  2. ポイントCとポイントAのストップは破られ,損失が増える
  3. フィボナッチリトレースメント比率の範囲のようなパラメータは,さらなる最適化が必要です

オプティマイゼーションの方向性

  1. ABCパターンの確認を支援するより多くの技術指標を組み込み,信号の正確性を向上させる
  2. より多くの市場条件に合わせてフィボナッチリトレースメント比率範囲を最適化
  3. ABCパターン認識モデルを訓練するために機械学習方法を活用する

結論

この戦略は,主要なサポート/レジスタンスレベルのピボットポイント確認とフィボナッチリトレースメント比計算に基づいて,トレンドターニングポイントでロング/ショート信号を生成するためのABCパターンを特定する.論理はシンプルで清潔で,リスクを効果的に制御する合理的な利益/損失ルールがあります.しかし,いくつかの誤判リスクは残っており,より多くの市場条件に適合するためにさらなる最適化と改善が必要です.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-19 23:59:59
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kerok3g

//@version=5
strategy("ABCD Strategy", shorttitle="ABCDS", overlay=true, commission_value=0.04)
calcdev(fprice, lprice, fbars, lbars) =>
    rise = lprice - fprice
    run = lbars - fbars
    avg = rise/run
    ((bar_index - lbars) * avg) + lprice

len = input(5)

ph = ta.pivothigh(len, len)
pl = ta.pivotlow(len, len)

var bool ishigh = false
ishigh := ishigh[1]

var float currph = 0.0
var int currphb = 0
currph := nz(currph)
currphb := nz(currphb)

var float oldph = 0.0
var int oldphb = 0
oldph := nz(oldph)
oldphb := nz(oldphb)

var float currpl = 0.0
var int currplb = 0
currpl := nz(currpl)
currplb := nz(currplb)

var float oldpl = 0.0
var int oldplb = 0
oldpl := nz(oldpl)
oldplb := nz(oldplb)

if (not na(ph))
    ishigh := true
    oldph := currph
    oldphb := currphb
    currph := ph
    currphb := bar_index[len]
else
    if (not na(pl))
        ishigh := false
        oldpl := currpl
        oldplb := currplb
        currpl := pl
        currplb := bar_index[len]

endHighPoint = calcdev(oldph, currph, oldphb, currphb)
endLowPoint = calcdev(oldpl, currpl, oldplb, currplb)

plotshape(ph, style=shape.triangledown, color=color.red, location=location.abovebar, offset=-len)
plotshape(pl, style=shape.triangleup, color=color.green, location=location.belowbar, offset=-len)

// var line lnhigher = na
// var line lnlower = na
// lnhigher := line.new(oldphb, oldph, bar_index, endHighPoint)
// lnlower := line.new(oldplb, oldpl, bar_index, endLowPoint)
// line.delete(lnhigher[1])
// line.delete(lnlower[1])

formlong = oldphb < oldplb and oldpl < currphb and currphb < currplb
longratio1 = (currph - oldpl) / (oldph - oldpl)
longratio2 = (currph - currpl) / (currph - oldpl)

formshort = oldplb < oldphb and oldphb < currplb and currplb < currphb
shortratio1 = (oldph - currpl) / (oldph - oldpl)
shortratio2 = (currph - currpl) / (oldph - currpl)

// prevent multiple entry for one pattern
var int signalid = 0
signalid := nz(signalid[1])

longCond = formlong and 
           longratio1 < 0.7 and 
           longratio1 > 0.5 and 
           longratio2 > 1.1 and 
           longratio2 < 1.35 and 
           close < oldph and 
           close > currpl and 
           signalid != oldplb
if (longCond)
    signalid := oldplb
    longsl = currpl - ta.tr
    longtp = ((close - longsl) * 1.5) + close
    strategy.entry("Long", strategy.long)
    strategy.exit("Exit Long", "Long", limit=math.min(longtp, oldph), stop=longsl)

shortCond = formshort and 
             shortratio1 < 0.7 and 
             shortratio1 > 0.5 and 
             shortratio2 > 1.1 and 
             shortratio2 < 1.35 and 
             close > oldpl and 
             close < currph and 
             signalid != oldphb

if (shortCond)
    signalid := oldphb
    shortsl = currph + ta.tr
    shorttp = close - ((shortsl - close) * 1.5)
    strategy.entry("Short", strategy.short)
    strategy.exit("Exit Short", "Short", limit=math.max(shorttp, oldpl), stop=shortsl)


もっと