
Die Strategie ist ein quantitatives Handelssystem, das eine Kombination aus Moving Average (MA) -Kreuzung und Trendverfolgung verwendet. Sie verwendet den 15-Zyklus-SMA (SMA) als Trendfilter, während die Kreuzung der 9-Zyklus- und 21-Zyklus-Index-Moving Average (EMA) genutzt wird, um Handelssignale zu erzeugen. Die Strategie verwendet strenge Einstiegsbedingungen und ein festes 1: 4-Risiko-Gewinn-Verhältnis, um das Risiko zu verwalten.
Die Kernlogik der Strategie basiert auf den folgenden Schlüsselelementen:
Dies ist eine Strategie, die durch eine Kombination aus mehreren technischen Indikatoren und einem strengen Risikomanagement eine gute Praxis hat. Obwohl einige inhärente Risiken bestehen, kann die Stabilität und Profitabilität der Strategie durch die empfohlene Optimierungsrichtung weiter verbessert werden. Die Strategie ist besonders geeignet für die Anwendung in Märkten mit deutlichen Trends und wird empfohlen, sie in mittleren und langen Zeiträumen zu verwenden.
/*backtest
start: 2024-02-21 00:00:00
end: 2024-12-19 00:00:00
period: 4d
basePeriod: 4d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("EMA Crossover Strategy with 15 SMA Trend", overlay=true, margin_long=100, margin_short=100)
// Calculate Indicators
sma15 = ta.sma(close, 15)
ema9 = ta.ema(close, 9)
ema21 = ta.ema(close, 21)
// Trend Detection
uptrend = close > sma15
downtrend = close < sma15
// Crossover Conditions
goldenCross = ta.crossover(ema9, ema21)
deathCross = ta.crossunder(ema9, ema21)
// Candle Conditions
twoBullish = (close > open) and (close[1] > open[1])
bearishCandle = (close < open)
// Entry Conditions
longCondition = goldenCross and uptrend and twoBullish and (ema9 > sma15) and (ema21 > sma15)
shortCondition = deathCross and downtrend and bearishCandle and (ema9 < sma15) and (ema21 < sma15)
// Risk Management
var float longStop = na
var float longTarget = na
var float shortStop = na
var float shortTarget = na
if longCondition
longStop := low
longTarget := close + 4*(close - longStop)
strategy.entry("Long", strategy.long)
strategy.exit("Long Exit", "Long", stop=longStop, limit=longTarget)
if shortCondition
shortStop := high
shortTarget := close - 4*(shortStop - close)
strategy.entry("Short", strategy.short)
strategy.exit("Short Exit", "Short", stop=shortStop, limit=shortTarget)
// Visual Elements
plot(sma15, "15 SMA", color=color.orange)
plot(ema9, "9 EMA", color=color.blue)
plot(ema21, "21 EMA", color=color.red)
// Plot trading levels
plot(longCondition ? longStop : na, "Long Stop", color=color.red, style=plot.style_linebr)
plot(longCondition ? longTarget : na, "Long Target", color=color.green, style=plot.style_linebr)
plot(shortCondition ? shortStop : na, "Short Stop", color=color.red, style=plot.style_linebr)
plot(shortCondition ? shortTarget : na, "Short Target", color=color.green, style=plot.style_linebr)
// Signal Markers
plotshape(longCondition, "Buy", shape.triangleup, location.belowbar, color=color.green, size=size.small)
plotshape(shortCondition, "Sell", shape.triangledown, location.abovebar, color=color.red, size=size.small)