
Diese Strategie beurteilt die Überbuying-Überverkaufssituation des Marktes durch Berechnung der Abweichung des Goldpreises vom 21. Index-Moving Average in Kombination mit der Standardabweichung. Wenn die Abweichung eine bestimmte Standardabweichung erreicht, wird eine Trendverfolgungsstrategie angewendet, während ein Stop-Loss-Mechanismus eingerichtet wird, um das Risiko zu kontrollieren.
Dies ist eine Trend-Tracking-Strategie, bei der der Markt überkauft und überverkauft wird, basierend auf Preisdynamik und Standarddifferenz, mit folgenden Vorteilen:
Die Strategie birgt auch einige Risiken:
Die Lösung:
Diese Strategie kann in folgenden Bereichen optimiert werden:
Diese Strategie ist insgesamt eine grundlegende, vernünftige Trendverfolgungstrategie. Sie nutzt die beweglichen Mittel, um die Richtung der Haupttrends zu bestimmen, und kann durch die standardisierte Verarbeitung der Preisverschiebung die Überkauf-Überverkaufssituation des Marktes klar bestimmen, wodurch ein Handelssignal erzeugt wird. Die Einrichtung eines vernünftigen Stop-Loss-Verfahrens ermöglicht es der Strategie, das Risiko zu kontrollieren, während sie einen Gewinn garantiert. Durch die weitere Optimierung der Parameter und das Hinzufügen weiterer bedingter Beurteilungen kann die Strategie stabiler, zuverlässiger und mit starkem Anwendungswert gemacht werden.
/*backtest
start: 2024-01-20 00:00:00
end: 2024-02-19 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("GC Momentum Strategy with Stoploss and Limits", overlay=true)
// Input for the length of the EMA
ema_length = input.int(21, title="EMA Length", minval=1)
// Exponential function parameters
steepness = 2
// Calculate the EMA
ema = ta.ema(close, ema_length)
// Calculate the deviation of the close price from the EMA
deviation = close - ema
// Calculate the standard deviation of the deviation
std_dev = ta.stdev(deviation, ema_length)
// Calculate the Z-score
z_score = deviation / std_dev
// Long entry condition if Z-score crosses +0.5 and is below 3 standard deviations
long_condition = ta.crossover(z_score, 0.5)
// Short entry condition if Z-score crosses -0.5 and is above -3 standard deviations
short_condition = ta.crossunder(z_score, -0.5)
// Exit long position if Z-score converges below 0.5 from top
exit_long_condition = ta.crossunder(z_score, 0.5)
// Exit short position if Z-score converges above -0.5 from below
exit_short_condition = ta.crossover(z_score, -0.5)
// Stop loss condition if Z-score crosses above 3 or below -3
stop_loss_long = ta.crossover(z_score, 3)
stop_loss_short = ta.crossunder(z_score, -3)
// Enter and exit positions based on conditions
if (long_condition)
strategy.entry("Long", strategy.long)
if (short_condition)
strategy.entry("Short", strategy.short)
if (exit_long_condition)
strategy.close("Long")
if (exit_short_condition)
strategy.close("Short")
if (stop_loss_long)
strategy.close("Long")
if (stop_loss_short)
strategy.close("Short")
// Plot the Z-score on the chart
plot(z_score, title="Z-score", color=color.blue, linewidth=2)
// Optional: Plot zero lines for reference
hline(0.5, "Upper Threshold", color=color.red)
hline(-0.5, "Lower Threshold", color=color.green)