SuperTrend-Grundstrategie

Schriftsteller:ChaoZhang, Datum: 2023-10-11
Tags:

Übersicht

Die SuperTrend-Grundstrategie ist eine zuverlässige und profitable algorithmische Handelsstrategie, die auf drei leistungsstarken Indikatoren basiert: SuperTrend (ATR), RSI und EMA. Sie zielt darauf ab, die Richtung und Stärke der Markttrends zu identifizieren, an optimalen Punkten in den Markt einzutreten und auszutreten, wenn ein Stop-Loss oder Take-Profit erreicht wird.

Strategie Logik

Die Strategie verwendet den SuperTrend-Indikator, um festzustellen, ob der Preis in einem Auftrend oder Abwärtstrend ist.

Der RSI wird verwendet, um Überkauf/Überverkauf zu erkennen. Über 50 ist bullish und unter 50 bearish. Der RSI filtert falsche Signale aus.

Die EMA beurteilt die langfristige Trendrichtung. Über der EMA ist ein Aufwärtstrend, darunter ein Abwärtstrend. Sie bestätigt die Handelsrichtung.

Die Handelssignale sind:

Long-Entry: Preis über SuperTrend und RSI über 50 und Preis über EMA Long Exit: Preis schließt unter SuperTrend oder Stop Loss oder Take Profit

Kurzer Einstieg: Preis unter SuperTrend und RSI unter 50 und Preis unter EMA Kurzer Ausgang: Preis schließt über SuperTrend oder Stop Loss oder Take Profit

Stop-Loss und Take-Profit können als Prozentsatz des Einstiegspreises festgelegt werden.

Analyse der Vorteile

Die Vorteile dieser Strategie:

  1. Kombination von 3 Indikatoren, zuverlässige Trenderkennung

  2. SuperTrend identifiziert deutlich Auf- und Abwärtstrend

  3. RSI filtert falsche Ausbrüche aus, vermeidet Überkauf/Überverkauf

  4. EMA bestätigt die allgemeine Trendrichtung

  5. Einfache und klare Handelssignale, leicht zu verfolgen

  6. Anpassbare ATR-Periode, RSI-Parameter und EMA-Periode zur Optimierung

  7. Stop-Loss und Gewinngewinn zur Risikokontrolle

  8. Nur langer oder nur kurzer Modus für verschiedene Märkte

  9. Anwendbar für jeden Zeitrahmen

Risikoanalyse

Die wichtigsten Risiken:

  1. Verzögerung des SuperTrends bei der Trendumkehr kann zu Verlusten führen

  2. Kleine Stop-Loss-/Take-Profit-Aktivitäten können große Aktionen nicht erfassen

  3. Die EMA kann keine Trendumkehrpunkte erkennen

  4. Keine Abweichung festgestellt

  5. Es besteht immer noch Volatilitätsrisiko und Zeitrisiko.

Lösungen:

  1. Hinzufügen anderer Indikatoren zur Erkennung der Umkehrung

  2. Optimieren von Stop-Loss/Take-Profit

  3. Hinzufügen anderer Indikatoren zur Spot-Umkehrung

  4. Einbeziehung von Abweichungsindikatoren

  5. Anpassung der Positionsgröße

Optimierungsrichtlinien

Möglichkeiten zur Optimierung der Strategie:

  1. Optimierung der ATR-Periode für Empfindlichkeit und Stabilität

  2. Optimierung der RSI-Parameter für eine höhere Genauigkeit

  3. Optimierung der EMA-Periode für verschiedene Märkte

  4. Hinzufügen von Indikatoren wie MACD, KD für die Umkehrerkennung

  5. Hinzufügen von Abweichungsindikatoren

  6. Verwenden Sie Elliott-Wellen, um Umkehrungen zu erkennen

  7. Maschinelles Lernen zur dynamischen Optimierung von Parametern

  8. Erweiterte Stop-Loss-Algorithmen wie Trailing Stop-Loss

  9. Optimierung der Positionsgröße für verschiedene Volatilitäten

  10. Versuche komplexere Ein- und Ausstiegsbedingungen

Schlussfolgerung

Die SuperTrend-Grundstrategie integriert SuperTrend, RSI und EMA in ein einfaches und praktisches Trendfolgensystem. Sie identifiziert die Trendrichtung klar, filtert falsche Signale aus und bestätigt den Gesamttrend. Klare Eintritts-, Ausstiegs- und Stop-Loss-/Take-Profit-Konfiguration. Einfach zu bedienen, zuverlässige Rentabilität. Anwendbar auf jeden Zeitrahmen. Sie kann durch Optimierung von Parametern, Hinzufügen von Umkehrwerkzeugen, Verbesserung von Stops weiter optimiert werden, um ein leistungsfähigeres Handelssystem zu werden.


/*backtest
start: 2023-09-10 00:00:00
end: 2023-10-10 00:00:00
period: 2h
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/
// © JS_TechTrading

//@version=5
// strategy("Supertrend", overlay=true,default_qty_type =strategy.percent_of_equity,default_qty_value = 1,process_orders_on_close = false)

// group string////
var string group_text000="Choose Strategy"
var string group_text0="Supertrend Settings"
var string group_text0000="Ema Settings"
var string group_text00="Rsi Settings"
var string group_text1="Backtest Period"
var string group_text2="Trade Direction"
// var string group_text3="Quantity Settings"
var string group_text4="Sl/Tp Settings"
////////////////////
option_ch=input.string('Pullback',title = "Type Of Strategy",options =['Pullback','Simple'])

//atr period input supertrend 
atrPeriod = input(10, "ATR Length",group = group_text0)
factor = input.float(3.0, "Factor", step = 0.01,group=group_text0)

[supertrend, direction] = ta.supertrend(factor, atrPeriod)

bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)

fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)

long=direction < 0 ? supertrend : na
short=direction < 0? na : supertrend

longpos=false
shortpos=false

longpos :=long?true :short?false:longpos[1]
shortpos:=short?true:long?false:shortpos[1]

fin_pullbuy= (ta.crossunder(low[1],long) and long and high>high[1])
fin_pullsell=(ta.crossover(high[1],short) and short and low<low[1]) 

//Ema 1
on_ma=input.bool(true,"Ema Condition On/Off",group=group_text0000)
ma_len= input.int(200, minval=1, title="Ema Length",group = group_text0000)
ma_src = input.source(close, title="Ema Source",group = group_text0000)
ma_out = ta.ema(ma_src, ma_len)

ma_buy=on_ma?close>ma_out?true:false:true
ma_sell=on_ma?close<ma_out?true:false:true

// rsi indicator and condition
// Get user input
en_rsi    = input.bool(true,"Rsi Condition On/Off",group = group_text00)
rsiSource = input(title='RSI Source', defval=close,group = group_text00)
rsiLength = input(title='RSI Length', defval=14,group = group_text00)
rsiOverbought = input(title='RSI BUY Level', defval=50,group = group_text00)
rsiOversold   = input(title='RSI SELL Level', defval=50,group = group_text00)

// Get RSI value
rsiValue = ta.rsi(rsiSource, rsiLength)

rsi_buy=en_rsi?rsiValue>=rsiOverbought ?true:false:true
rsi_sell=en_rsi?rsiValue<=rsiOversold?true:false:true

// final condition
buy_cond=option_ch=='Simple'?long and not(longpos[1]) and rsi_buy and ma_buy:option_ch=='Pullback'?fin_pullbuy and rsi_buy and ma_buy:na
sell_cond=option_ch=='Simple'?short and not(shortpos[1]) and rsi_sell and ma_sell:option_ch=='Pullback'?fin_pullsell and rsi_sell and ma_sell:na

//backtest engine
start = input(timestamp('2005-01-01'), title='Start calculations from',group=group_text1)
end=input(timestamp('2045-03-01'), title='End calculations',group=group_text1)
time_cond =true

// Make input option to configure trade direction

tradeDirection = input.string(title='Trade Direction', options=['Long', 'Short', 'Both'], defval='Both',group = group_text2)

// Translate input into trading conditions
longOK  = (tradeDirection == "Long") or (tradeDirection == "Both")
shortOK = (tradeDirection == "Short") or (tradeDirection == "Both")



// strategy start
if buy_cond and longOK and time_cond and strategy.position_size==0
    strategy.entry('long',direction = strategy.long)
if sell_cond and shortOK and time_cond and strategy.position_size==0
    strategy.entry('short',direction =strategy.short)

// fixed percentage based stop loss and take profit 

// User Options to Change Inputs (%)
stopPer = input.float(1.0,step=0.10, title='Stop Loss %',group =group_text4) / 100
takePer = input.float(1.0,step =0.10, title='Take Profit %',group =group_text4) / 100

// Determine where you've entered and in what direction
longStop  = strategy.position_avg_price * (1 - stopPer)
shortStop = strategy.position_avg_price * (1 + stopPer)
shortTake = strategy.position_avg_price * (1 - takePer)
longTake  = strategy.position_avg_price * (1 + takePer)


if strategy.position_size > 0
    strategy.exit(id='Close Long',stop=longStop, limit=longTake)
if strategy.position_size < 0
    strategy.exit(id='Close Short',stop=shortStop, limit=shortTake)

//PLOT FIXED SLTP LINE
plot(strategy.position_size > 0 ? longStop : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Long Fixed SL')
plot(strategy.position_size < 0 ? shortStop :na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Short Fixed SL')
plot(strategy.position_size > 0 ? longTake : na, style=plot.style_linebr, color=color.new(color.green, 0), linewidth=1, title='Long Take Profit')
plot(strategy.position_size < 0 ? shortTake : na, style=plot.style_linebr, color=color.new(color.green, 0), linewidth=1, title='Short Take Profit')

//

Mehr