OPEN-SOURCE SCRIPT
MACD Histogram on RSI - Hex Colors

The Moving Average Convergence Divergence (MACD) indicator was developed by Gerald Appel in the late 1970s as a tool for identifying changes in momentum, trend strength, and direction in financial markets. Appel designed MACD to provide traders with a clearer view of market trends by comparing two exponential moving averages (EMAs) and their convergence or divergence over time. The indicator became widely popular due to its versatility—it helps traders recognize strong trends while also signaling potential reversals. Over the years, MACD has evolved, with refinements in interpretation and parameter settings, making it a staple in technical analysis. The most impotrtant indications given by MACD are divergences.
MACD divergences are classified into different types based on their strength and reliability in predicting trend reversals. Here are the main classes:
Class A Divergence: This is the strongest type of divergence. It occurs when the price makes a new high (or low), but the MACD fails to confirm it by making a lower high (or higher low). This signals a high probability of trend reversal.
Class B Divergence: In this case, the price forms a double top or double bottom, but the MACD does not reach a new extreme. This suggests a potential reversal but with less certainty compared to Class A.
Class C Divergence: The weakest form of divergence, where the price makes a new high or low, but the MACD forms a pattern similar to a double top or double bottom. This indicates a possible slowdown in momentum rather than a strong reversal.
These divergences help traders assess whether a trend is losing strength and may reverse.
Besides these, there are two other signals that traders should be aware of, viz, ZLR and Shamur signal.
The Zero Line Reject (ZLR) is a concept in MACD analysis where the MACD line approaches the zero line, briefly crosses it, and then reverses direction. This behavior suggests that the trend attempted to shift but failed, reinforcing the prevailing trend. Traders often interpret this as a continuation signal rather than a reversal.
The Shamur Signal, as some traders call it, is a variation of this pattern. It occurs when the MACD line drops below the zero line, rebounds above it, and then resumes its downward movement—or vice versa for bullish setups. This pattern can indicate a false breakout or a temporary shift in momentum before the trend resumes. The key takeaway is that the market attempted to reverse but lacked the strength to sustain the move, making it a potential opportunity for trend traders.
Now let's look at RSI(14) briefly: The Relative Strength Index (RSI) is a widely used momentum oscillator that measures the speed and magnitude of price movements to identify overbought and oversold conditions. Developed by J. Welles Wilder Jr. in 1978, RSI operates on a scale from 0 to 100, with readings above 70 typically indicating an overbought market and readings below 30 signaling an oversold market. Traders use RSI to assess trend strength, spot potential reversals, and confirm price movements. While effective in ranging markets, RSI can also be adapted with divergence analysis and dynamic thresholds to enhance its predictive power.
Now, the question arises why do we use an indicator on indicator?
Using indicator-on-indicator analysis enhances traditional technical indicators by applying secondary calculations to their values, unlocking deeper insights into market behavior. This method offers several advantages:
Refined Signal Filtering – Applying an indicator to another indicator smooths out noise, helping traders avoid false signals and focus on meaningful market trends. For example, using MACD on RSI can reveal momentum shifts that standard RSI alone might overlook.
Multi-Layered Confirmation – Instead of relying on a single indicator, traders get a more nuanced view of price movements. Secondary indicators reinforce decisions, improving accuracy in identifying trend strength and reversals.
Adaptive Market Analysis – Different market environments require different tools. Indicator-on-indicator techniques allow traders to fine-tune strategies based on changing volatility and momentum conditions rather than relying on static thresholds.
Creative Customization – Traders can mold indicators to fit their specific market approach. Whether refining entries/exits or detecting trend exhaustion, these hybrid setups provide tailored insights beyond conventional methods.
This approach is particularly useful for momentum and trend-based trading, offering a more dynamic perspective that adapts to price action in a way traditional indicators cannot.
What are the potential shortcomings of such an approach?
While indicator-on-indicator analysis can refine signals and enhance decision-making, it also comes with several drawbacks that traders should consider:
Lagging Effect – Since indicators are already derivatives of price action, stacking them introduces additional delays in responsiveness. This can lead to late entries or exits, reducing a strategy’s effectiveness in fast-moving markets.
Over-Filtering Signals – Applying an indicator to another can smooth out noise, but it may also suppress valuable early signals. Traders may miss key turning points if too much filtering dilutes the raw market momentum.
Complex Interpretation – Standard indicators have well-defined thresholds and behaviors, but once modified by another indicator, they can become harder to interpret. Traders may struggle to adapt existing strategies or find reliable patterns.
Reduced Versatility – Some hybrid indicators work well in specific market conditions but lose their edge in others. This dependency on particular trends or volatility levels can make a strategy less adaptable.
Potential Redundancy – If indicators are not chosen wisely, layering them may lead to excessive confirmation bias, where multiple indicators show similar information without providing any new insights.
While indicator-on-indicator techniques can refine analysis, careful calibration is required to balance precision with practicality.
The MACD on RSI Indicator merges two powerful momentum-based indicators, offering deeper insights into trend dynamics and market strength. By applying the MACD calculation to the RSI values instead of price, traders can detect subtle shifts in momentum that might be overlooked by traditional MACD or RSI alone.
This hybrid approach enhances trend confirmation, allowing traders to gauge whether RSI’s momentum aligns with MACD's trend direction. It helps in early signal detection, potentially revealing trend shifts before they appear on conventional setups. Additionally, it reduces false signals by filtering RSI fluctuations, making MACD more reactive to meaningful changes in strength rather than short-term noise.
By combining these indicators, traders can refine entries and exits based on momentum divergences, zero-line behaviors, and shifts in trend acceleration. The MACD on RSI setup is particularly useful in identifying trend exhaustion and continuation signals, making it a valuable tool in both ranging and trending markets.
I have primarily used this indicator to spot hidden divergences. So what are they?
Hidden divergences, sometimes referred to as reverse divergences, are a powerful yet often overlooked concept in technical analysis. Unlike regular divergences, which signal potential trend reversals, hidden divergences indicate trend continuation—suggesting that the prevailing trend is likely to persist despite temporary price fluctuations.
Hidden divergences occur when the price makes a higher low in an uptrend or a lower high in a downtrend, while the oscillator (such as RSI, MACD, or Stochastic) forms a lower low or higher high, respectively. This discrepancy suggests that momentum is still strong in the direction of the trend, even though price action may appear to weaken momentarily.
Types of Hidden Divergences
---------------------------------------------------------
Hidden Bullish Divergence: Price forms a higher low, but the oscillator prints a lower low. This signals that the uptrend remains intact and is likely to continue.
Hidden Bearish Divergence: Price forms a lower high, but the oscillator prints a higher high. This suggests that the downtrend is still dominant and likely to persist.
Why Hidden Divergences Matter
Hidden divergences are particularly useful for trend-following traders, as they provide early confirmation that a trend is still strong despite minor pullbacks. They help traders avoid premature exits and reinforce confidence in holding positions longer. Additionally, hidden divergences can serve as entry signals, allowing traders to position themselves in the direction of the trend before a new wave of momentum unfolds.
Key Considerations
While hidden divergences are valuable, they should not be used in isolation. Combining them with support/resistance levels, volume analysis, and price action confirmation enhances their reliability. Additionally, they tend to work best in strong trending markets, where momentum indicators align with price direction.
By mastering hidden divergences, traders can refine their ability to ride trends effectively, reducing the risk of exiting too soon or misinterpreting temporary pullbacks as reversals.
In my trading, I have used this indicator since 2009. My general aim is to make it available to all my friends. If you are using it, you are also my friend. So happy trading.
MACD divergences are classified into different types based on their strength and reliability in predicting trend reversals. Here are the main classes:
Class A Divergence: This is the strongest type of divergence. It occurs when the price makes a new high (or low), but the MACD fails to confirm it by making a lower high (or higher low). This signals a high probability of trend reversal.
Class B Divergence: In this case, the price forms a double top or double bottom, but the MACD does not reach a new extreme. This suggests a potential reversal but with less certainty compared to Class A.
Class C Divergence: The weakest form of divergence, where the price makes a new high or low, but the MACD forms a pattern similar to a double top or double bottom. This indicates a possible slowdown in momentum rather than a strong reversal.
These divergences help traders assess whether a trend is losing strength and may reverse.
Besides these, there are two other signals that traders should be aware of, viz, ZLR and Shamur signal.
The Zero Line Reject (ZLR) is a concept in MACD analysis where the MACD line approaches the zero line, briefly crosses it, and then reverses direction. This behavior suggests that the trend attempted to shift but failed, reinforcing the prevailing trend. Traders often interpret this as a continuation signal rather than a reversal.
The Shamur Signal, as some traders call it, is a variation of this pattern. It occurs when the MACD line drops below the zero line, rebounds above it, and then resumes its downward movement—or vice versa for bullish setups. This pattern can indicate a false breakout or a temporary shift in momentum before the trend resumes. The key takeaway is that the market attempted to reverse but lacked the strength to sustain the move, making it a potential opportunity for trend traders.
Now let's look at RSI(14) briefly: The Relative Strength Index (RSI) is a widely used momentum oscillator that measures the speed and magnitude of price movements to identify overbought and oversold conditions. Developed by J. Welles Wilder Jr. in 1978, RSI operates on a scale from 0 to 100, with readings above 70 typically indicating an overbought market and readings below 30 signaling an oversold market. Traders use RSI to assess trend strength, spot potential reversals, and confirm price movements. While effective in ranging markets, RSI can also be adapted with divergence analysis and dynamic thresholds to enhance its predictive power.
Now, the question arises why do we use an indicator on indicator?
Using indicator-on-indicator analysis enhances traditional technical indicators by applying secondary calculations to their values, unlocking deeper insights into market behavior. This method offers several advantages:
Refined Signal Filtering – Applying an indicator to another indicator smooths out noise, helping traders avoid false signals and focus on meaningful market trends. For example, using MACD on RSI can reveal momentum shifts that standard RSI alone might overlook.
Multi-Layered Confirmation – Instead of relying on a single indicator, traders get a more nuanced view of price movements. Secondary indicators reinforce decisions, improving accuracy in identifying trend strength and reversals.
Adaptive Market Analysis – Different market environments require different tools. Indicator-on-indicator techniques allow traders to fine-tune strategies based on changing volatility and momentum conditions rather than relying on static thresholds.
Creative Customization – Traders can mold indicators to fit their specific market approach. Whether refining entries/exits or detecting trend exhaustion, these hybrid setups provide tailored insights beyond conventional methods.
This approach is particularly useful for momentum and trend-based trading, offering a more dynamic perspective that adapts to price action in a way traditional indicators cannot.
What are the potential shortcomings of such an approach?
While indicator-on-indicator analysis can refine signals and enhance decision-making, it also comes with several drawbacks that traders should consider:
Lagging Effect – Since indicators are already derivatives of price action, stacking them introduces additional delays in responsiveness. This can lead to late entries or exits, reducing a strategy’s effectiveness in fast-moving markets.
Over-Filtering Signals – Applying an indicator to another can smooth out noise, but it may also suppress valuable early signals. Traders may miss key turning points if too much filtering dilutes the raw market momentum.
Complex Interpretation – Standard indicators have well-defined thresholds and behaviors, but once modified by another indicator, they can become harder to interpret. Traders may struggle to adapt existing strategies or find reliable patterns.
Reduced Versatility – Some hybrid indicators work well in specific market conditions but lose their edge in others. This dependency on particular trends or volatility levels can make a strategy less adaptable.
Potential Redundancy – If indicators are not chosen wisely, layering them may lead to excessive confirmation bias, where multiple indicators show similar information without providing any new insights.
While indicator-on-indicator techniques can refine analysis, careful calibration is required to balance precision with practicality.
The MACD on RSI Indicator merges two powerful momentum-based indicators, offering deeper insights into trend dynamics and market strength. By applying the MACD calculation to the RSI values instead of price, traders can detect subtle shifts in momentum that might be overlooked by traditional MACD or RSI alone.
This hybrid approach enhances trend confirmation, allowing traders to gauge whether RSI’s momentum aligns with MACD's trend direction. It helps in early signal detection, potentially revealing trend shifts before they appear on conventional setups. Additionally, it reduces false signals by filtering RSI fluctuations, making MACD more reactive to meaningful changes in strength rather than short-term noise.
By combining these indicators, traders can refine entries and exits based on momentum divergences, zero-line behaviors, and shifts in trend acceleration. The MACD on RSI setup is particularly useful in identifying trend exhaustion and continuation signals, making it a valuable tool in both ranging and trending markets.
I have primarily used this indicator to spot hidden divergences. So what are they?
Hidden divergences, sometimes referred to as reverse divergences, are a powerful yet often overlooked concept in technical analysis. Unlike regular divergences, which signal potential trend reversals, hidden divergences indicate trend continuation—suggesting that the prevailing trend is likely to persist despite temporary price fluctuations.
Hidden divergences occur when the price makes a higher low in an uptrend or a lower high in a downtrend, while the oscillator (such as RSI, MACD, or Stochastic) forms a lower low or higher high, respectively. This discrepancy suggests that momentum is still strong in the direction of the trend, even though price action may appear to weaken momentarily.
Types of Hidden Divergences
---------------------------------------------------------
Hidden Bullish Divergence: Price forms a higher low, but the oscillator prints a lower low. This signals that the uptrend remains intact and is likely to continue.
Hidden Bearish Divergence: Price forms a lower high, but the oscillator prints a higher high. This suggests that the downtrend is still dominant and likely to persist.
Why Hidden Divergences Matter
Hidden divergences are particularly useful for trend-following traders, as they provide early confirmation that a trend is still strong despite minor pullbacks. They help traders avoid premature exits and reinforce confidence in holding positions longer. Additionally, hidden divergences can serve as entry signals, allowing traders to position themselves in the direction of the trend before a new wave of momentum unfolds.
Key Considerations
While hidden divergences are valuable, they should not be used in isolation. Combining them with support/resistance levels, volume analysis, and price action confirmation enhances their reliability. Additionally, they tend to work best in strong trending markets, where momentum indicators align with price direction.
By mastering hidden divergences, traders can refine their ability to ride trends effectively, reducing the risk of exiting too soon or misinterpreting temporary pullbacks as reversals.
In my trading, I have used this indicator since 2009. My general aim is to make it available to all my friends. If you are using it, you are also my friend. So happy trading.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。