
Diese Strategie basiert auf der Kreuzung von Preisen mit beweglichen Durchschnitten, um Kauf- und Verkaufssignale zu erzeugen. Sie bietet verschiedene Arten von beweglichen Durchschnitten und einen Kompromiss-Parameter, um falsche Durchbrüche zu filtern. Die Strategie zielt darauf ab, Wendepunkte in der Preisentwicklung zu erfassen und eine Trendverfolgung zu ermöglichen.
Die Strategie basiert auf dem Preis-Knopf-Preis und berechnet einen Moving Average mit einer Länge von N. Typische Moving Average-Typen sind einfache Moving Averages (SMA), Index Moving Averages (EMA), Gewichtete Moving Averages (WMA) und so weiter. Dann wird ein Kompromissniveau, wie z. B. 5%, festgelegt und ein Auftriebs- und Eintrittssignal berechnet.
Die Strategie ist insgesamt eine eher typische Trend-Tracking-Strategie. Sie nutzt die Beziehung zwischen dem Preis und dem Moving Average, um Trends zu beurteilen, und bietet eine gewisse Flexibilität. Durch die Optimierung der Parameter und die richtige Signalfilterung kann sie eine gut funktionierende quantitative Strategie sein.
/*backtest
start: 2023-12-26 00:00:00
end: 2024-01-25 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/
// © RafaelPiccolo
//@version=4
strategy("Price X MA Cross", overlay=true)
typ = input("HMA", "MA Type", options=["SMA", "EMA", "WMA", "HMA", "VWMA", "RMA", "TEMA"])
len = input(100, minval=1, title="Length")
src = input(close, "Source", type=input.source)
tol = input(0, minval=0, title="Tolerance (%)", type=input.float)
shortOnly = input(false, "Short only")
tema(src, len)=>
ema1 = ema(src, len)
ema2 = ema(ema1, len)
ema3 = ema(ema2, len)
return = 3 * (ema1 - ema2) + ema3
getMAPoint(type, len, src)=>
return = type == "SMA" ? sma(src, len) : type == "EMA" ? ema(src, len) : type == "WMA" ? wma(src, len) : type == "HMA" ? hma(src, len) : type == "VWMA" ? vwma(src, len) : type == "RMA" ? rma(src, len) : tema(src, len)
ma = getMAPoint(typ, len, src)
upperTol = ma * (1 + tol/100)
lowerTol = ma * (1 - tol/100)
longCondition = crossover(close, upperTol)
shortCondition = crossunder(close, lowerTol)
if (shortCondition)
strategy.entry("Short", strategy.short)
if (longCondition)
if (shortOnly)
strategy.close("Short")
else
strategy.entry("Long", strategy.long)
plot(ma, "Moving Average", close > ma ? color.green : color.red, linewidth = 2)
t1 = plot(tol > 0 ? upperTol : na, transp = 70)
t2 = plot(tol > 0 ? lowerTol : na, transp = 70)
fill(t1, t2, color = tol > 0 ? color.blue : na)