
La stratégie est un système de trading intelligent basé sur les signaux de croisement MACD. Il génère des signaux d’achat et de vente en analysant les croisements entre les lignes MACD et les lignes de signal et en les affichant visuellement sur des graphiques. Le système intègre des rappels en temps réel pour informer les traders des opportunités de trading potentielles.
Le cœur de la stratégie est d’utiliser l’indicateur MACD pour capturer les changements de dynamique du marché. La mise en œuvre comprend les étapes clés suivantes:
Il s’agit d’un système de stratégies de croisement MACD entièrement structuré et logiquement clair. Il fournit aux traders un outil de négociation objectif grâce à une présentation visuelle et à une exécution automatisée. Bien qu’il existe un certain risque de retard, la stabilité et la fiabilité de la stratégie peuvent être encore améliorées grâce à une orientation d’optimisation recommandée.
/*backtest
start: 2024-02-10 00:00:00
end: 2025-02-09 00:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("ETH/USD MACD Crossover", overlay=true)
// MACD settings
fastLength = input(12, title="Fast EMA Length")
slowLength = input(26, title="Slow EMA Length")
signalLength = input(9, title="Signal Line Length")
// MACD calculation
[macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalLength)
// Plot MACD and Signal Line
plot(macdLine, color=color.blue, title="MACD Line", linewidth=2)
plot(signalLine, color=color.orange, title="Signal Line", linewidth=2)
hline(0, "Zero Line", color=color.gray)
// MACD Histogram
macdHistogram = macdLine - signalLine
plot(macdHistogram, color=macdHistogram >= 0 ? color.green : color.red, style=plot.style_histogram, title="MACD Histogram")
// Buy and Sell Conditions
buyCondition = ta.crossover(macdLine, signalLine) // MACD crosses above Signal Line
sellCondition = ta.crossunder(macdLine, signalLine) // MACD crosses below Signal Line
// Plot buy/sell signals on the chart
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Alerts for buy/sell conditions
if (buyCondition)
alert("MACD Crossover: BUY signal for ETH/USD", alert.freq_once_per_bar)
if (sellCondition)
alert("MACD Crossover: SELL signal for ETH/USD", alert.freq_once_per_bar)
// Strategy entry/exit
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.close("Buy")