Cette stratégie est basée sur la version à décalage zéro de l'indicateur MACD (Moving Average Convergence Divergence), qui capture les tendances à court terme en répondant rapidement aux changements de prix, permettant un trading à haute fréquence.
La stratégie de trading MACD à double croisement Zero Lag permet de réaliser des transactions à haute fréquence en répondant rapidement aux changements de prix et en capturant les tendances à court terme. L'algorithme à zéro retard et la conception de moyenne mobile double améliorent la rapidité et l'exactitude des signaux. La stratégie présente certains avantages, tels que des signaux intuitifs et un fonctionnement pratique, mais elle comporte également des risques tels que le surtrading et la sensibilité des paramètres.
/*backtest start: 2024-04-23 00:00:00 end: 2024-05-23 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy("BNM INTRADAY SETUP MACD 3M - Version 1.2", shorttitle="Zero Lag MACD Enhanced 1.2") source = close fastLength = input(12, title="Fast MM period", minval=1) slowLength = input(26,title="Slow MM period", minval=1) signalLength =input(9,title="Signal MM period", minval=1) useEma = input(true, title="Use EMA (otherwise SMA)") useOldAlgo = input(false, title="Use Glaz algo (otherwise 'real' original zero lag)") showDots = input(true, title="Show symbols to indicate crossing") dotsDistance = input(1.5, title="Symbols distance factor", minval=0.1) // Fast line ma1 = useEma ? ema(source, fastLength) : sma(source, fastLength) ma2 = useEma ? ema(ma1, fastLength) : sma(ma1, fastLength) zerolagEMA = ((2 * ma1) - ma2) // Slow line mas1 = useEma ? ema(source, slowLength) : sma(source, slowLength) mas2 = useEma ? ema(mas1, slowLength) : sma(mas1, slowLength) zerolagslowMA = ((2 * mas1) - mas2) // MACD line ZeroLagMACD = zerolagEMA - zerolagslowMA // Signal line emasig1 = ema(ZeroLagMACD, signalLength) emasig2 = ema(emasig1, signalLength) signal = useOldAlgo ? sma(ZeroLagMACD, signalLength) : (2 * emasig1) - emasig2 hist = ZeroLagMACD - signal upHist = (hist > 0) ? hist : 0 downHist = (hist <= 0) ? hist : 0 p1 = plot(upHist, color=color.blue, transp=40, style=plot.style_columns, title='Positive delta') p2 = plot(downHist, color=color.red, transp=40, style=plot.style_columns, title='Negative delta') zeroLine = plot(ZeroLagMACD, color=color.red, transp=0, linewidth=2, title='MACD line') signalLine = plot(signal, color=color.blue, transp=0, linewidth=2, title='Signal') ribbonDiff = hist > 0 ? color.blue : color.red fill(zeroLine, signalLine, color=ribbonDiff) circleYPosition = signal * dotsDistance ribbonDiff2 = hist > 0 ? color.blue : color.red // Generate dots for cross signals plot(showDots and cross(ZeroLagMACD, signal) ? circleYPosition : na, style=plot.style_circles, linewidth=4, color=ribbonDiff2, title='Dots') // Alerts for buy and sell signals buySignal = cross(ZeroLagMACD, signal) and (ribbonDiff2 == color.blue) and (ZeroLagMACD < 0) sellSignal = cross(ZeroLagMACD, signal) and (ribbonDiff2 == color.red) and (ZeroLagMACD > 0) // Use 'strategy.entry' for placing orders in strategy context if (buySignal) strategy.entry("Buy", strategy.long) alert("Buy Signal: Blue dot below zero line", alert.freq_once_per_bar_close) if (sellSignal) strategy.entry("Sell", strategy.short) alert("Sell Signal: Red dot above zero line", alert.freq_once_per_bar_close)