
La stratégie est un système de trading quantifié basé sur les indicateurs MACD et EMA à périodes multiples. La stratégie construit un système de prise de décision de trading complet en combinant les caractéristiques de suivi de tendance de l’indicateur MACD et les caractéristiques de résistance au support de plusieurs courbes EMA. Le système comprend non seulement la génération de signaux d’achat et de vente, mais intègre également une fonction d’alerte en temps réel qui aide les traders à saisir les opportunités de marché en temps opportun.
La logique centrale de la stratégie est basée sur deux principaux indicateurs techniques. Le premier est l’indicateur MACD, composé d’une ligne rapide (circuit 12) et d’une ligne lente (circuit 26), qui génère un signal de transaction par la croisée des deux lignes.
Cette stratégie, combinée au MACD et aux EMA pluricycliques, permet de construire un système de négociation plus complet. L’avantage du système réside dans la clarté des signaux, la richesse de l’analyse et une bonne visualisation. Mais il existe également des risques inhérents tels que le retard et les faux signaux.
/*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")