
Die Strategie verwendet zwei Index-Moving Averages (EMA) um Veränderungen in der Preisentwicklung zu erfassen. Wenn ein kurzfristiger EMA einen langfristigen EMA von unten durchquert, erzeugt dies ein Kaufsignal. Wenn ein kurzfristiger EMA einen langfristigen EMA von oben durchquert, erzeugt dies ein Verkaufsignal. Die Strategie setzt gleichzeitig eine tägliche Stop-Loss- und Stop-Stop-Begrenzung, um Ein-Tages-Verluste und -Gewinne zu kontrollieren.
Die EMA-Doppel-Gleichgewichts-Kreuzung ist eine einfache, leicht zu verstehende Handelsstrategie, die für den Trendmarkt geeignet ist. Durch die schnelle und langsame Kreuzung der Mittellinie können die Änderungen der Preisentwicklung besser erfasst werden. Die Einstellung von täglichen Stop-Loss- und Stop-Stops kann das Risiko effektiv kontrollieren. Die Strategie kann jedoch in einem bewegten Markt oder bei einer Trendwende schlechter abschneiden und muss in Kombination mit anderen technischen Indikatoren und Analysemethoden optimiert und verbessert werden.
/*backtest
start: 2023-06-01 00:00:00
end: 2024-06-06 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DD173838
//@version=5
strategy("Moving Average Strategy with Daily Limits", overlay=true)
// Moving Average settings
shortMaLength = input.int(9, title="Short MA Length")
longMaLength = input.int(21, title="Long MA Length")
// Calculate MAs
shortMa = ta.ema(close, shortMaLength)
longMa = ta.ema(close, longMaLength)
// Plot MAs
plot(shortMa, title="9 EMA", color=color.blue)
plot(longMa, title="21 EMA", color=color.red)
// Strategy conditions
crossUp = ta.crossover(shortMa, longMa)
crossDown = ta.crossunder(shortMa, longMa)
// Debug plots to check cross conditions
plotshape(series=crossUp, title="Cross Up", location=location.belowbar, color=color.green, style=shape.labelup, text="UP")
plotshape(series=crossDown, title="Cross Down", location=location.abovebar, color=color.red, style=shape.labeldown, text="DOWN")
// Entry at cross signals
if (crossUp)
strategy.entry("Long", strategy.long)
if (crossDown)
strategy.entry("Short", strategy.short)
// Daily drawdown and profit limits
var float startOfDayEquity = na
if (na(startOfDayEquity) or ta.change(time('D')) != 0)
startOfDayEquity := strategy.equity
maxDailyLoss = 50000 * 0.0025
maxDailyProfit = 50000 * 0.02
currentDailyPL = strategy.equity - startOfDayEquity
if (currentDailyPL <= -maxDailyLoss)
strategy.close_all(comment="Max Daily Loss Reached")
if (currentDailyPL >= maxDailyProfit)
strategy.close_all(comment="Max Daily Profit Reached")