Strategie für die durchschnittliche Umkehrung der Dynamik

Schriftsteller:ChaoZhang, Datum: 2023-11-15 17:40:59
Tags:

img

Übersicht

Die mittlere Umschlagdynamikstrategie ist eine Trendhandelsstrategie, die kurzfristige Preisdurchschnitte verfolgt.

Strategie Logik

Die Strategie berechnet zunächst die mittlere Umkehrlinie und die Standardabweichung des Preises. Dann, kombiniert mit den Schwellenwerten, die von den Parametern Ober- und Unterschwellen festgelegt wurden, berechnet sie, ob der Preis den Bereich von einer Standardabweichung von der mittleren Umkehrlinie überschreitet. Wenn ja, wird ein Handelssignal generiert.

Bei Longsignalen muss der Preis um eine Standardabweichung unterhalb der mittleren Umkehrlinie liegen, der Schlusskurs unterhalb der SMA der LENGTH-Periode und über der TREND SMA, wenn diese drei Bedingungen erfüllt sind, wird eine Longposition eröffnet. Die Schlusskondition ist, wenn der Preis über die SMA der LENGTH-Periode bricht.

Für Short-Signale muss der Preis um eine Standardabweichung über der mittleren Umkehrlinie liegen, der Schlusskurs ist über dem SMA der LENGTH-Periode und unter dem TREND-SMA, wenn diese drei Bedingungen erfüllt sind, wird eine Short-Position eröffnet. Die Schlusskondition ist, wenn der Preis unter den SMA der LENGTH-Periode bricht.

Die Strategie kombiniert auch das Prozentsatzgewinnziel und den Prozentsatz Stop Loss für die Gewinnentnahme und das Stop Loss Management.

Die Exitmethode kann zwischen einem gleitenden Durchschnitts- oder einem linearen Regressions-Crossover wählen.

Durch die Kombination von zweispurigem Handel, Trendfilterung, Gewinnentnahme und Stop-Loss usw. wird das Urteilen und die Verfolgung mittelfristiger Markttrends realisiert.

Vorteile

  1. Der Indikator für die mittlere Umkehrung kann die Abweichung des Preises vom Wertzentrum effektiv beurteilen.

  2. Der Momentum-Indikator SMA kann kurzfristige Marktgeräusche filtern.

  3. Der zweiseitige Handel kann Trendchancen in alle Richtungen vollständig nutzen.

  4. Der Profit-taking- und Stop-Loss-Mechanismus kann Risiken wirksam kontrollieren.

  5. Die auswählbaren Ausstiegsmethoden können flexibel an die Marktbedingungen angepasst werden.

  6. Eine vollständige Trend-Handelsstrategie, die mittelfristige Trends besser erfasst.

Risiken

  1. Der Indikator für die mittlere Umkehrung ist empfindlich auf Parameter-Einstellungen angewiesen; eine unsachgemäße Einstellung des Schwellenwerts kann zu falschen Signalen führen.

  2. In volatilen Marktbedingungen kann ein Stop-Loss zu häufig ausgelöst werden.

  3. Bei seitlichen Trends kann die Handelsfrequenz zu hoch sein, wodurch die Handelskosten und das Risiko von Verschiebungen steigen.

  4. Wenn das Handelsinstrument über unzureichende Liquidität verfügt, kann die Schlupfkontrolle nicht optimal sein.

  5. Der zweiseitige Handel birgt höhere Risiken, daher ist eine umsichtige Geldverwaltung erforderlich.

Diese Risiken können durch Parameteroptimierung, Stop-Loss-Anpassung, Geldmanagement usw. kontrolliert werden.

Optimierungsrichtlinien

  1. Optimierung der Parameter-Einstellungen der Indikatoren für mittlere Reversion und Momentum, um sie besser an verschiedene Handelsinstrumente anzupassen.

  2. Hinzufügen von Trend-Identifikationsindikatoren zur Verbesserung der Fähigkeit zur Trenderkennung.

  3. Optimierung der Stop-Loss-Strategie, um sich besser an bedeutende Marktschwankungen anzupassen.

  4. Hinzufügen von Positionsgrößenmodulen zur Anpassung der Positionsgrößen an die Marktbedingungen.

  5. Zusätzliche Risikomanagement-Module, wie z. B. Kontrolle der maximalen Anziehung, Steuerung der Eigenkapitalkurve usw.

  6. Die Kombination von Methoden des maschinellen Lernens zur automatischen Optimierung von Strategieparametern.

Zusammenfassung

Zusammenfassend lässt sich sagen, dass die Mittelumkehrmomentumsstrategie mittelfristige Mittelumkehrtrends durch ein einfaches und effektives Indikatordesign erfasst. Die Strategie hat eine starke Anpassungsfähigkeit und Vielseitigkeit, hat aber auch einige Risiken. Durch kontinuierliche Optimierung und Kombination mit anderen Strategien kann eine bessere Leistung erzielt werden. Insgesamt ist die Strategie ziemlich vollständig und ist eine Trendhandelsmethode, die es wert ist, berücksichtigt zu werden.


/*backtest
start: 2023-10-15 00:00:00
end: 2023-11-14 00:00:00
period: 1h
basePeriod: 15m
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/
// © GlobalMarketSignals

//@version=4
strategy("GMS: Mean Reversion Strategy", overlay=true)

LongShort       = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"])
Lookback        = input(title="Length", type=input.integer, defval=10, minval=0)
LThr1           = input(title="Upper threshold", type=input.float, defval=1, minval=0)
LThr            = input(title="Lower threshold", type=input.float, defval=-1, maxval=0)
src             = input(title="Source", type=input.source, defval=close)
LongShort2      = input(title="Linear Regression Exit or Moving Average Exit?", type=input.string, defval="MA", options=["LR", "MA"])
SMAlenL         = input(title="MA/LR Exit Length", type = input.integer ,defval=10)
SMALen2         = input(title="Trend SMA Length", type = input.integer ,defval=200)
AboveBelow      = input(title="Above or Below Trend SMA?", type=input.string, defval="Above", options=["Above", "Below", "Don't Include"])
PTbutton        = input(title="Profit Target On/Off", type=input.bool, defval=true)
ProfitTarget    = input(title="Profit Target %", type=input.float, defval=1, step=0.1, minval=0)
SLbutton        = input(title="Stop Loss On/Off", type=input.bool, defval=true)
StopLoss        = input(title="Stop Loss %", type=input.float, defval=-1, step=0.1, maxval=0)

x               = (src-linreg(src,Lookback,0))/(stdev(src,Lookback))

plot(linreg(src,Lookback,0))

//PROFIT TARGET & STOPLOSS

if PTbutton == true and SLbutton == true
    strategy.exit("EXIT", profit=((close*(ProfitTarget*0.01))/syminfo.mintick), loss=((close*(StopLoss*-0.01))/syminfo.mintick))
else
    if PTbutton == true and SLbutton == false
        strategy.exit("PT EXIT", profit=((close*(ProfitTarget*0.01))/syminfo.mintick))
    else
        if PTbutton == false and SLbutton == true
            strategy.exit("SL EXIT", loss=((close*(StopLoss*-0.01))/syminfo.mintick))
        else    
            strategy.cancel("PT EXIT")


////////////////////////
//MOVING AVERAGE EXIT//
//////////////////////

if LongShort=="Long Only" and AboveBelow=="Above" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close>sma(close,SMALen2))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort=="Long Only" and AboveBelow=="Below" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close<sma(close,SMALen2))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort=="Long Only" and AboveBelow=="Don't Include" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) )
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
///////    
    
if LongShort=="Short Only" and AboveBelow=="Above" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close>sma(close,SMALen2))
    strategy.close("SHORT", when = close<sma(close,SMAlenL))

if LongShort=="Short Only" and AboveBelow=="Below" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL)   and close<sma(close,SMALen2))
    strategy.close("SHORT", when = close<sma(close,SMAlenL))

if LongShort=="Short Only" and AboveBelow=="Don't Include" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1  and close>sma(close,SMAlenL)  )
    strategy.close("SHORT", when = close<sma(close,SMAlenL))
    
//////

if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close>sma(close,SMALen2))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close<sma(close,SMALen2))
    strategy.close("LONG", when = close>sma(close,SMAlenL))

if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="MA"
    strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) )
    strategy.close("LONG", when = close>sma(close,SMAlenL))
    
///////    
    
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close>sma(close,SMALen2))
    strategy.close("SHORT", when = close<sma(close,SMAlenL))

if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close<sma(close,SMALen2))
    strategy.close("SHORT", when = close<sma(close,SMAlenL))

if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="MA"
    strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) )
    strategy.close("SHORT", when = close<sma(close,SMAlenL))
    
/////////////////
//LIN REG EXIT//
///////////////

if LongShort=="Long Only" and AboveBelow=="Above" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))

if LongShort=="Long Only" and AboveBelow=="Below" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))

if LongShort=="Long Only" and AboveBelow=="Don't Include" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) )
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
    
///////    
    
if LongShort=="Short Only" and AboveBelow=="Above" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))

if LongShort=="Short Only" and AboveBelow=="Below" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0)   and close<sma(close,SMALen2))
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))

if LongShort=="Short Only" and AboveBelow=="Don't Include" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1  and close>linreg(close,SMAlenL,0)  )
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
    
//////

if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))

if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))

if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="LR"
    strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) )
    strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
    
///////    
    
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))

if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))

if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="LR"
    strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) )
    strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))






Mehr