
Die Strategie ist ein quantitatives Handelssystem, das auf MACD- und mehrperiodischen EMA-Indikatoren basiert. Die Strategie baut ein vollständiges Handelsentscheidungssystem auf, indem sie die Trend-Tracking-Eigenschaften des MACD-Indikators und die Unterstützungs-Widerstands-Eigenschaften mehrerer EMA-Gleichlinien kombiniert. Das System enthält nicht nur die Generierung von Kauf- und Verkaufssignalen, sondern auch eine integrierte Echtzeit-Vorwarnfunktion, die dem Händler hilft, Marktchancen rechtzeitig zu erfassen.
Die Kernlogik der Strategie basiert auf zwei wichtigen technischen Indikatoren. Erstens ist der MACD-Indikator, der aus einer schnellen Linie (12 Zyklen) und einer langsamen Linie (26 Zyklen) besteht, die ein Handelssignal durch die Kreuzung der beiden Linien erzeugt. Wenn die MACD-Linie die Signallinie überquert, wird ein Kaufsignal erzeugt, wenn sie untergeht, wird ein Verkaufssignal erzeugt.
Die Strategie kombiniert MACD und Multi-Perioden-EMA-Indikatoren, um ein relativ vollständiges Handelssystem zu erstellen. Die Vorteile des Systems liegen in der Signalklarheit, der Analysedimensionalität und der guten Visualisierung. Es gibt jedoch auch die inhärenten Risiken wie Lagerung und Falschsignale.
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("REEL TIME MACD Strategy with Alerts and EMAs", overlay=true)
// --- Custom Indicator: MACD ---
fastLength = input(12, title="MACD Fast Length")
slowLength = input(26, title="MACD Slow Length")
signalSmoothing = input(9, title="MACD Signal Smoothing")
src = close
[macdLine, signalLine, _] = ta.macd(src, fastLength, slowLength, signalSmoothing)
histogram = macdLine - signalLine
// Plot MACD components
plot(macdLine, color=color.blue, linewidth=2, title="MACD Line")
plot(signalLine, color=color.orange, linewidth=2, title="Signal Line")
plot(histogram, style=plot.style_histogram, color=(histogram >= 0 ? color.green : color.red), title="Histogram")
// --- Custom Indicator: EMAs ---
ema10 = ta.ema(src, 10)
ema20 = ta.ema(src, 20)
ema50 = ta.ema(src, 50)
ema100 = ta.ema(src, 100)
ema200 = ta.ema(src, 200)
// Plot EMAs on the chart
plot(ema10, color=color.green, linewidth=1, title="EMA 10")
plot(ema20, color=color.blue, linewidth=1, title="EMA 20")
plot(ema50, color=color.purple, linewidth=1, title="EMA 50")
plot(ema100, color=color.orange, linewidth=1, title="EMA 100")
plot(ema200, color=color.red, linewidth=1, title="EMA 200")
// --- Strategy: Buy and Sell conditions (MACD) ---
buyCondition = ta.crossover(macdLine, signalLine) // Buy when MACD crosses above signal line
sellCondition = ta.crossunder(macdLine, signalLine) // Sell when MACD crosses below signal line
// Execute strategy based on buy/sell conditions
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.close("Buy")
// --- Alerts ---
alertcondition(buyCondition, title="MACD Buy Alert", message="MACD XUP - Buy")
alertcondition(sellCondition, title="MACD Sell Alert", message="MACD XDN - Sell")
// Optional: Visualization for Buy/Sell signals
plotshape(series=buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")
plotshape(series=sellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL")