OPEN-SOURCE SCRIPT
MACD PRO

Moving Average Convergence Divergence PRO (MACD Pro) — with Crosses & Divergence
A classic MACD indicator enhanced with two practical additions: visual cross markers and automatic divergence detection.
What it shows
The standard MACD setup — fast and slow moving averages of price, their difference plotted as the MACD line, a signal line smoothing of that difference, and a histogram showing the gap between them. Histogram bars use a four-tone color scheme that shows both the side of zero and whether momentum is accelerating or decelerating.
Cross markers
Whenever the MACD line crosses the signal line, a small X is plotted at the bottom of the pane (bullish cross) or the top (bearish cross). Colors are configurable. This makes it easy to spot every cross at a glance without staring at where the two lines meet, which can be hard to read on busy charts or smaller timeframes.
Divergence detection
Optional pivot-based divergence detection between price and the MACD line, with four divergence types you can toggle independently:
Regular bullish — price makes a lower low while MACD makes a higher low (potential reversal up)
Regular bearish — price makes a higher high while MACD makes a lower high (potential reversal down)
Hidden bullish — price makes a higher low while MACD makes a lower low (trend continuation in an uptrend)
Hidden bearish — price makes a lower high while MACD makes a higher high (trend continuation in a downtrend)
When a divergence is confirmed, the indicator draws a line connecting the two MACD pivots and prints a labeled marker. Pivot sensitivity, plus the minimum and maximum bar distance between pivots, are all configurable so you can tune the signal frequency to your timeframe and instrument.
Inputs
Standard MACD parameters (source, fast/slow/signal lengths, EMA or SMA for each), plus separate groups for cross marker visibility and divergence settings.
Alerts
Built-in alert conditions for histogram state changes, MACD/signal crosses in either direction, and each divergence type — eight in total.
Notes
Divergence is inherently lagging by the right-side pivot lookback, since a pivot can only be confirmed once the required number of bars to its right have printed. This is true of all pivot-based divergence indicators and is unavoidable; a signal that appears on the chart will be drawn back at the actual pivot bar but won't be detectable in real time until that confirmation completes. Treat divergence as context, not a trigger.
A classic MACD indicator enhanced with two practical additions: visual cross markers and automatic divergence detection.
What it shows
The standard MACD setup — fast and slow moving averages of price, their difference plotted as the MACD line, a signal line smoothing of that difference, and a histogram showing the gap between them. Histogram bars use a four-tone color scheme that shows both the side of zero and whether momentum is accelerating or decelerating.
Cross markers
Whenever the MACD line crosses the signal line, a small X is plotted at the bottom of the pane (bullish cross) or the top (bearish cross). Colors are configurable. This makes it easy to spot every cross at a glance without staring at where the two lines meet, which can be hard to read on busy charts or smaller timeframes.
Divergence detection
Optional pivot-based divergence detection between price and the MACD line, with four divergence types you can toggle independently:
Regular bullish — price makes a lower low while MACD makes a higher low (potential reversal up)
Regular bearish — price makes a higher high while MACD makes a lower high (potential reversal down)
Hidden bullish — price makes a higher low while MACD makes a lower low (trend continuation in an uptrend)
Hidden bearish — price makes a lower high while MACD makes a higher high (trend continuation in a downtrend)
When a divergence is confirmed, the indicator draws a line connecting the two MACD pivots and prints a labeled marker. Pivot sensitivity, plus the minimum and maximum bar distance between pivots, are all configurable so you can tune the signal frequency to your timeframe and instrument.
Inputs
Standard MACD parameters (source, fast/slow/signal lengths, EMA or SMA for each), plus separate groups for cross marker visibility and divergence settings.
Alerts
Built-in alert conditions for histogram state changes, MACD/signal crosses in either direction, and each divergence type — eight in total.
Notes
Divergence is inherently lagging by the right-side pivot lookback, since a pivot can only be confirmed once the required number of bars to its right have printed. This is true of all pivot-based divergence indicators and is unavoidable; a signal that appears on the chart will be drawn back at the actual pivot bar but won't be detectable in real time until that confirmation completes. Treat divergence as context, not a trigger.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。