Dreifach gleitender Durchschnittskanaltrend nach Strategie

Schriftsteller:ChaoZhang, Datum: 2023-11-06 16:58:57
Tags:

img

Übersicht

Diese Strategie verwendet eine dreifache Kombination von gleitenden Durchschnitten, um die Trendrichtung basierend auf der Reihenfolge der gleitenden Durchschnitte zu bestimmen, um einen Trend zu erreichen.

Strategieprinzip

Die Strategie verwendet drei gleitende Durchschnitte mit unterschiedlichen Perioden, darunter einen schnellen gleitenden Durchschnitt, einen mittleren gleitenden Durchschnitt und einen langsamen gleitenden Durchschnitt.

Eintrittsbedingungen:

  1. Long: Wenn ein schneller MA > mittlerer MA > langsamer MA ein Aufwärtstrend aufweist, wird der Markt als lang angesehen.
  2. Kurz: Wenn ein langsamer MA < mittlerer MA < schneller MA, der Markt in einem Abwärtstrend ist, geht man kurz.

Ausgangsbedingungen:

  1. MA-Ausgang: Schließung der Position, wenn sich die Reihenfolge der drei gleitenden Durchschnitte umkehrt.
  2. TP/SL-Ausgang: Festgefasste Gewinn- und Stop-Loss-Punkte, z. B. 12% für TP und 1% für SL, aussteigen, wenn der Preis TP oder SL erreicht.

Die Strategie ist einfach und direkt und verwendet drei gleitende Durchschnitte, um die Markttrendrichtung für den Trend nach dem Handel zu bestimmen, die für Märkte mit starkem Trend geeignet ist.

Analyse der Vorteile

  • Verwenden Sie drei gleitende Durchschnitte, um den Trend zu bestimmen und Marktlärm zu filtern.
  • Die gleitenden Durchschnittswerte für verschiedene Zeiträume können die Trendumkehrpunkte genauer bestimmen.
  • Kombination von gleitenden Durchschnittsindikatoren und festem TP/SL zur Steuerung des Kapitalrisikos.
  • Die Strategielogik ist einfach und intuitiv, leicht zu verstehen und umzusetzen.
  • Die MA-Periodenparameter lassen sich leicht an die Marktbedingungen verschiedener Zyklen anpassen.

Risiken und Verbesserungen

  • In langen Zyklusmärkten können gleitende Durchschnitte mehr falsche Signale haben, was zu unnötigen Verlusten führt.
  • Es sollte in Betracht gezogen werden, weitere Indikatoren oder Filter hinzuzufügen, um die Rentabilität zu verbessern.
  • Optimierung der Kombination von gleitenden Durchschnittsperiodenparametern zur Anpassung an umfassendere Marktbedingungen.
  • Kombination mit Trendstärkenindikatoren, um Höchstkäufe und Tiefkäufe zu vermeiden.
  • Fügen Sie automatische Stopps hinzu, um Verluste zu vermeiden.

Schlussfolgerung

Die Triple Moving Average Trend Following Strategie hat eine klare und leicht verständliche Logik und verwendet gleitende Durchschnitte, um die Trendrichtung für einfache Trends nach dem Handel zu bestimmen. Der Vorteil ist, dass sie einfach zu implementieren ist und die Anpassung der MA-Periodenparameter sich an die Marktbedingungen verschiedener Zyklen anpassen kann. Es gibt jedoch auch bestimmte Risiken für falsche Signale, die durch Hinzufügen anderer Indikatoren oder Bedingungen verbessert werden können, um unnötige Verluste zu reduzieren und die Rentabilität der Strategie zu verbessern. Insgesamt eignet sich diese Strategie für Anfänger, die sich für den Trendhandel interessieren, um zu lernen und zu üben.


/*backtest
start: 2023-10-06 00:00:00
end: 2023-11-05 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/
// © Jompatan

//@version=5
strategy('Strategy Triple Moving Average', overlay=true, initial_capital = 1000, commission_value=0.04, max_labels_count=200)

//INPUTS
mov_ave = input.string(defval="EMA", title='Moving Average type:', options= ["EMA", "SMA"])

period_1 = input.int(9,  title='Period 1', inline="1", group= "============== Moving Average Inputs ==============")
period_2 = input.int(21, title='Period 2', inline="2", group= "============== Moving Average Inputs ==============")
period_3 = input.int(50, title='Period 3', inline="3", group= "============== Moving Average Inputs ==============")

source_1 = input.source(close, title='Source 1', inline="1", group= "============== Moving Average Inputs ==============")
source_2 = input.source(close, title='Source 2', inline="2", group= "============== Moving Average Inputs ==============")
source_3 = input.source(close, title='Source 3', inline="3", group= "============== Moving Average Inputs ==============")


//EXIT CONDITIONS
exit_ma   = input.bool(true, title= "Exit by Moving average condition", group="================ EXIT CONDITIONS ================")
exit_TPSL = input.bool(false, title= "Exit by Take Profit and StopLoss", group="================ EXIT CONDITIONS ================")
TP        = input.int(12, title='Take Profit', step=1, group="================ EXIT CONDITIONS ================")
SL        = input.int(1, title='Stop Loss', step=1, group="================ EXIT CONDITIONS ================")
plot_TPSL = input.bool(false, title='Show TP/SL lines', group="================ EXIT CONDITIONS ================")


//Date filters
desde = input(defval= timestamp("01 Jan 2023 00:00 -3000"), title="From", inline="12", group= "============= DATE FILTERS =============")
hasta = input(defval= timestamp("01 Oct 2099 00:00 -3000"), title="To  ", inline="13", group= "============= DATE FILTERS =============")
enRango = true

//COMMENTS
//entry_long_comment  = input.string(defval=" ", title="Entry Long comment: ", inline="14", group="============= COMMENTS =============")
//exit_long_comment   = input.string(defval=" ", title="Exit Long comment:  ", inline="15", group="============= COMMENTS =============")
//entry_short_comment = input.string(defval=" ", title="Entry Short comment:", inline="16", group="============= COMMENTS =============")
//exit_short_comment  = input.string(defval=" ", title="Exit Short comment: ", inline="17", group="============= COMMENTS =============")

//============================================================

//Selecting Moving average type
ma1 = mov_ave == "EMA" ? ta.ema(source_1, period_1) : ta.sma(source_1, period_1)
ma2 = mov_ave == "EMA" ? ta.ema(source_2, period_2) : ta.sma(source_2, period_2)
ma3 = mov_ave == "EMA" ? ta.ema(source_3, period_3) : ta.sma(source_3, period_3)

//============================================================
//Entry Long condition: Grouped Moving average from: (ma fast > ma middle > ma slow)
long_condition = (ma1 > ma2) and (ma2 > ma3)

//Entry Short condition: Grouped Moving average from: (ma fast < ma middle < ma slow)
short_condition = (ma1 < ma2) and (ma2 < ma3)

//============================================================

cantidad       = strategy.equity / close
comprado_long  = strategy.position_size > 0
comprado_short = strategy.position_size < 0

var long_profit_price  = 0.0
var long_stop_price    = 0.0
var short_profit_price = 0.0
var short_stop_price   = 0.0

//============================================================

//ENTRY LONG
if not comprado_long and not comprado_short and long_condition and not long_condition[1] and enRango
    strategy.entry('Long', strategy.long, qty=cantidad, comment= "Entry Long")
    if exit_TPSL
        long_profit_price := close * (1 + TP/100)
        long_stop_price   := close * (1 - SL/100)
    else
        long_profit_price := na
        long_stop_price   := na
//============================================================


//ENTRY SHORT
if not comprado_long and not comprado_short and short_condition and not short_condition[1] and enRango
    strategy.entry('Short', strategy.short, qty=cantidad, comment= "Entry Short")
    if exit_TPSL
        short_profit_price := close * (1 - TP/100)
        short_stop_price   := close * (1 + SL/100)
    else
        short_profit_price := na
        short_stop_price   := na
//============================================================


//EXIT LONG 
if comprado_long and exit_ma and long_condition[1] and not long_condition
    strategy.close('Long', comment='Exit-Long(MA)')
if comprado_long and exit_TPSL
    strategy.exit('Long', limit=long_profit_price, stop=long_stop_price, comment='Exit-Long(TP/SL)')
//============================================================


//EXIT SHORT 
if comprado_short and exit_ma and short_condition[1] and not short_condition
    strategy.close('Short', comment='Exit-Short(MA)')
if comprado_short and exit_TPSL
    strategy.exit('Short', limit=short_profit_price, stop=short_stop_price, comment='Exit-Short(TP/SL)')
//============================================================



//PLOTS
plot(ma1, linewidth=2, color=color.rgb(255, 255, 255))
plot(ma2, linewidth=2, color=color.rgb(144, 255, 252))
plot(ma3, linewidth=2, color=color.rgb(49, 167, 255))
//Plot Take Profit line
plot(plot_TPSL ? comprado_long  ? long_profit_price : comprado_short ? short_profit_price : na : na, color=color.new(color.lime, 30), style= plot.style_linebr)
//Plot StopLoss line
plot(plot_TPSL ? comprado_long ? long_stop_price : comprado_short ? short_stop_price : na : na, color=color.new(color.red, 30), style= plot.style_linebr)









Mehr