Automatischer Trend basierend auf Pivot Point und Fibonacci Retracement nach Strategie

Schriftsteller:ChaoZhang, Datum: 2024-01-05 11:34:17
Tags:

img

Übersicht

Diese Strategie identifiziert automatisch ABC-Muster in Aktienkursen basierend auf Drehpunkten und Fibonacci-Retracement-Verhältnissen und erzeugt Long/Short-Signale. Sie verwendet Drehpunkte, um Preiswellen zu bestimmen und berechnet Fibonacci-Retracement-Verhältnisse zwischen ABC-Wellen. Wenn die Verhältnisse bestimmte Kriterien erfüllen, werden Handelssignale generiert.

Strategie Logik

  1. Berechnen Sie die Pivot-Hoch- und Tiefpunkte der Aktie
  2. Beurteilen, ob der Preis vom vorherigen Höchststand zurückgegangen ist oder vom vorherigen Tiefstand gestiegen ist
  3. Berechnen Sie die Fibonacci-Retracement-Verhältnis zwischen der aktuellen Welle und der vorherigen Welle
  4. Wenn die Rückzugsquoten der beiden Auf- und Abwellen innerhalb der richtigen Grenzen liegen, bestimmt man ein mögliches ABC-Muster
  5. Nach der Bestätigung des ABC-Musters setzen Sie den Stop-Loss auf Punkt C für lang und auf Punkt A für kurz.

Analyse der Vorteile

  1. Pivotpunkte identifizieren wichtige Unterstützungs-/Widerstandsniveaus zur Verbesserung der Signalgenauigkeit
  2. Fibonacci-Retracements fangen Trendwendepunkte auf, indem sie ABC-Muster identifizieren
  3. Klarer Gewinn-Verlust-Ansatz verhindert große Verluste

Risikoanalyse

  1. Pivotpunkte und Fibonacci-Retracements können nicht die perfekte Identifizierung aller Trendwendepunkte gewährleisten.
  2. Punkt C und Punkt A können durchbrochen werden, was zu größeren Verlusten führt
  3. Parameter wie Fibonacci-Retracement-Ratio-Bereiche müssen weiter optimiert werden

Optimierungsrichtlinien

  1. Mehr technische Indikatoren zur Unterstützung der Bestätigung von ABC-Mustern, um die Signalgenauigkeit zu verbessern
  2. Optimieren Sie die Fibonacci-Retracement-Reihe für mehr Marktbedingungen
  3. Verwenden von Methoden des maschinellen Lernens zur Ausbildung von ABC-Mustererkennungsmodellen

Schlussfolgerung

Diese Strategie identifiziert ABC-Muster für die Erzeugung von Long/Short-Signalen an Trend-Wendepunkten, basierend auf der Pivot-Point-Bestätigung der wichtigsten Unterstützungs-/Widerstandsniveaus und Fibonacci-Retracement-Ratio-Berechnungen.


/*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)


Mehr