Doppel gleitender Durchschnittstrend nach Strategie

Schriftsteller:ChaoZhang, Datum: 2023-09-18 21:57:00
Tags:

Übersicht

Diese Strategie verwendet schnelle und langsame gleitende Durchschnitte, um die Trendrichtung zu identifizieren und Signale zu erzeugen, wenn ein schneller MA einen langsamen MA überquert, wodurch ein duales MA-System geschaffen wird.

Grundsätze

Die Strategie setzt einen kürzeren schnellen und einen längeren langsamen MA ein.

Der langsame MA definiert die Haupttrendrichtung. Der Preis über dem MA ist Aufwärtstrend, der Preis darunter ist Abwärtstrend.

Bei Aufwärtstrends wird ein langes Signal erzeugt, wenn ein schneller MA über einen langsamen MA überschreitet.

Nach dem Signal kann der Hinterhalt optional aktiviert werden.

Vorteile

  1. Die Kombination von schneller und langsamer MA identifiziert effektiv den Trend.

  2. Fast MA erzeugt sensible Handelssignale.

  3. Langsamer MA filtert Lärm und verhindert einen falschen Ausbruch.

  4. Es können verschiedene MA-Typen wie EMA, DEMA verwendet werden.

  5. Der Stop-Loss kann aktiviert werden.

Risiken und Minderungsmaßnahmen

  1. Eine Verzögerung der MA-Verzögerung kann die Signale verzögern. Sensiblere Parameter können getestet werden.

  2. Der Stop-Loss könnte zu eng sein, was zu einem vorzeitigen Ausstieg führt.

  3. Das Volumen wird ignoriert, es besteht die Gefahr einer Preismanipulation.

  4. Nur Anzeiger sind anfällig für falsche Signale.

  5. Parameteroptimierung schwierig. Schrittweise Optimierung oder GA kann optimale Parameter finden.

Möglichkeiten zur Verbesserung

  1. Versuche verschiedene MA-Typen und -parameter für optimale Ergebnisse.

  2. Suchen Sie nach Adaptive Moving Averages für eine bessere Empfindlichkeit.

  3. Hinzufügen anderer Indikatoren oder Faktoren für die Signalfilterung.

  4. Dynamische Haltestellen für flexible Haltestellen.

  5. Optimieren Sie das Geldmanagement wie dynamische Positionsgröße mit ATR.

Zusammenfassung

Die Strategie handelt mit doppelten MA-Kreuzungen, um Trends zu identifizieren, wobei Stops das Risiko begrenzen. Die Logik ist einfach und klar, aber die Parameterwahl und andere Probleme bestehen. Verbesserungen durch Optimierung, Filterung, Stops können die Robustheit verbessern. Es dient als ein vernünftiges Baseline-Trendfolgensystem.


/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy(title = "Noro's Trend MAs Strategy v1.7", shorttitle = "Trend MAs str 1.7", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value=100.0, pyramiding=0)

//Settings
needlong = input(true, "long")
needshort = input(true, "short")
needstops = input(false, "stops")
stoppercent = input(5, defval = 5, minval = 1, maxval = 50, title = "Stop, %")
type = input(7, defval = 7, minval = 1, maxval = 7, title = "Type of Slow MA")
src = input(close, defval = close, title = "Source of Slow MA")
usefastsma = input(true, "Use fast MA Filter")
fastlen = input(5, defval = 5, minval = 1, maxval = 50, title = "fast MA Period")
len = input(20, defval = 20, minval = 2, maxval = 200, title = "slow MA Period")
bars = input(2, defval = 2, minval = 0, maxval = 3, title = "Bars Q")
needbg = input(false, defval = false, title = "Need trend Background?")
needarr = input(false, defval = false, title = "Need entry arrows?")

fastsma = ema(src, fastlen)

//DEMA
dema = 2 * ema(src, len) - ema(ema(close, len), len)

//TEMA
xPrice = close
xEMA1 = ema(src, len)
xEMA2 = ema(xEMA1, len)
xEMA3 = ema(xEMA2, len)
tema = 3 * xEMA1 - 3 * xEMA2 + xEMA3

//KAMA
xvnoise = abs(src - src[1])
nfastend = 0.20
nslowend = 0.05
nsignal = abs(src - src[len])
nnoise = sum(xvnoise, len)
nefratio = iff(nnoise != 0, nsignal / nnoise, 0)
nsmooth = pow(nefratio * (nfastend - nslowend) + nslowend, 2) 
kama = nz(kama[1]) + nsmooth * (src - nz(kama[1]))

//PriceChannel
lasthigh = highest(src, len)
lastlow = lowest(src, len)
center = (lasthigh + lastlow) / 2

//Trend
ma = type == 1 ? sma(src, len) : type == 2 ? ema(src, len) : type == 3 ? vwma(src, len) : type == 4 ? dema : type == 5 ? tema : type == 6 ? kama : type == 7 ? center : 0
trend = low > ma and low[1] > ma[1] and low[2] > ma[2] ? 1 : high < ma and high[1] < ma[1] ? -1 : trend[1]

//Bars
bar = close > open ? 1 : close < open ? -1 : 0
redbars = bars == 0 ? 1 : bars == 1 and bar == -1 ? 1 : bars == 2 and bar == -1 and bar[1] == -1 ? 1 : bars == 3 and bar == -1 and bar[1] == -1 and bar[2] == -1 ? 1 : 0
greenbars = bars == 0 ? 1 : bars == 1 and bar == 1 ? 1 : bars == 2 and bar == 1 and bar[1] == 1 ? 1 : bars == 3 and bar == 1 and bar[1] == 1 and bar[2] == 1 ? 1 : 0

//Signals
min = min(open, close)
max = max(open, close)
up = trend == 1 and (low < fastsma or usefastsma == false) and redbars == 1 ? 1 : 0
dn = trend == -1 and (high > fastsma or usefastsma == false) and greenbars == 1 ? 1 : 0

//Lines
colorfastsma = usefastsma == true ? red : na
plot(fastsma, color = colorfastsma, title = "Fast MA")
plot(ma, color = blue, linewidth = 3, transp = 0, title = "Slow MA")

//Arrows
plotarrow(up == 1 and needarr == true ? 1 : 0, colorup = black, colordown = black, transp = 0)
plotarrow(dn == 1 and needarr == true ? -1 : 0, colorup = black, colordown = black, transp = 0)

//Background
col = needbg == false ? na : trend == 1 ? lime : red
bgcolor(col, transp = 90)

//Alerts
alertcondition(up == 1, title='buy', message='Uptrend')
alertcondition(dn == 1, title='sell', message='Downtrend')

//Trading
stoplong = up == 1 and needstops == true ? close - (close / 100 * stoppercent) : stoplong[1]
stopshort = dn == 1 and needstops == true ? close + (close / 100 * stoppercent) : stopshort[1]

longCondition = up == 1
if (longCondition)
    strategy.entry("Long", strategy.long, needlong == false ? 0 : na)
    strategy.exit("Stop Long", "Long", stop = stoplong)

shortCondition = dn == 1
if (shortCondition)
    strategy.entry("Short", strategy.short, needshort == false ? 0 : na)
    strategy.exit("Stop Short", "Short", stop = stopshort)

Mehr