OPEN-SOURCE SCRIPT
已更新 MACD Slope & Swing Monitor

This script is not just another MACD. It is a highly specialized momentum engine designed to quantify trend exhaustion and visualize structural pivots, making it the perfect tool for trading advanced concepts like the "Anti-Setup" (popularized by Linda Raschke) and Hidden Divergences.
While standard MACD shows you the current momentum, it often lags during complex corrections (like Elliott Wave 4th waves or Flat corrections). This indicator solves this by introducing real-time Slope Quantification and past Swing Pivot Detection.
Key Features & The Logic Behind the Mashup:
Dynamic Slope Quantification: Calculates the exact rate of change (Slope) for both the MACD and Signal lines over a user-defined lookback period. This allows traders to spot momentum decay before an actual crossover occurs. The exact values are displayed on a clean, dynamic label that tracks the current bar.
Structural Swing Detection (Pivots): Uses a 5-bar left/right lookback to plot Swing Highs and Lows directly on the oscillator. By locking these markers to the top and bottom of the pane, the script keeps the MACD lines perfectly clean. This is crucial for instantly identifying Hidden Divergences against previous structural peaks.
Custom MA Engine: Unlike standard built-in MACD, this script allows you to independently change the Moving Average type (SMA, EMA, WMA, RMA) for both the Oscillator and the Signal line. (e.g., using EMA for the oscillator and SMA for the signal to refine trade timing).
How to Use:
Trend Continuation (Hidden Divergence): Look for price to make a Lower High / Higher Low, while the MACD Swing markers show a Higher High / Lower Low.
The "Anti" Trigger: Wait for the MACD Slope to sharply reverse back toward the Signal line in the direction of the primary trend. The real-time label will confirm the momentum shift mathematically before the visual hook forms.
While standard MACD shows you the current momentum, it often lags during complex corrections (like Elliott Wave 4th waves or Flat corrections). This indicator solves this by introducing real-time Slope Quantification and past Swing Pivot Detection.
Key Features & The Logic Behind the Mashup:
Dynamic Slope Quantification: Calculates the exact rate of change (Slope) for both the MACD and Signal lines over a user-defined lookback period. This allows traders to spot momentum decay before an actual crossover occurs. The exact values are displayed on a clean, dynamic label that tracks the current bar.
Structural Swing Detection (Pivots): Uses a 5-bar left/right lookback to plot Swing Highs and Lows directly on the oscillator. By locking these markers to the top and bottom of the pane, the script keeps the MACD lines perfectly clean. This is crucial for instantly identifying Hidden Divergences against previous structural peaks.
Custom MA Engine: Unlike standard built-in MACD, this script allows you to independently change the Moving Average type (SMA, EMA, WMA, RMA) for both the Oscillator and the Signal line. (e.g., using EMA for the oscillator and SMA for the signal to refine trade timing).
How to Use:
Trend Continuation (Hidden Divergence): Look for price to make a Lower High / Higher Low, while the MACD Swing markers show a Higher High / Lower Low.
The "Anti" Trigger: Wait for the MACD Slope to sharply reverse back toward the Signal line in the direction of the primary trend. The real-time label will confirm the momentum shift mathematically before the visual hook forms.
發行說明
Update: Adjustable Pivot Sensitivity & Dashboard UIIn this update, I have refined the visual clarity and added customization options to help you better adapt to different market volatilities.
1. Adjustable Swing Pivot Sensitivity (Noise Filter)
You can now fully customize the lookback period (Left and Right Bars) for Swing High/Low detection directly from the settings menu.
The default lookback has been increased from 5 to 7. This provides a stronger filter against minor market noise, allowing you to focus purely on major structural swings for higher-probability Hidden Divergence and "Anti" setups.
The marker offset now dynamically adapts to your chosen right-bar period, ensuring perfect visual alignment on the chart.
2. Fixed Dashboard UI (Slope Monitor)
Upgraded the real-time Slope Monitor display. Instead of a floating label that follows the last candle, the exact slope values are now locked into a clean, fixed Table Dashboard (Top Right).
This keeps the MACD oscillator completely free of clutter, giving you a pure view of the momentum waves while the crucial numbers remain constantly visible in your peripheral vision.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。