OPEN-SOURCE SCRIPT
Smart Price Divergence (MACD Filter) + EMA

📌 Purpose
This indicator detects Price Divergences with MACD filtered by a 200 EMA trend condition.
It helps identify high-probability reversal zones aligned with market trend context.
🧠 How It Works
1. MACD Divergence Logic
Bearish Divergence:
Price makes a higher high.
MACD makes a lower high.
Price is above EMA (indicating possible exhaustion in bullish trend).
Bullish Divergence:
Price makes a lower low.
MACD makes a higher low.
Price is below EMA (indicating possible exhaustion in bearish trend).
2. EMA Trend Filter
EMA(200) is used as a directional filter:
Bearish divergences considered above EMA (extended bullish conditions).
Bullish divergences considered below EMA (extended bearish conditions).
3. Visual & Alerts
EMA(200) plotted on chart in orange.
Red triangles for Bearish Divergence.
Green triangles for Bullish Divergence.
Alerts fire for both divergence types.
📈 How to Use
Look for divergence signals as potential reversal alerts.
Combine with support/resistance or price action for confirmation.
EMA ensures signals occur in extended zones, increasing reliability.
Recommended Timeframes: 1h, 4h, D.
Markets: Forex, Crypto, Stocks.
⚙️ Inputs
MACD Fast / Slow / Signal Length
EMA Length (default 200)
⚠️ Disclaimer
This script is for educational purposes only. It does not constitute financial advice.
Always test thoroughly before live trading.
This indicator detects Price Divergences with MACD filtered by a 200 EMA trend condition.
It helps identify high-probability reversal zones aligned with market trend context.
🧠 How It Works
1. MACD Divergence Logic
Bearish Divergence:
Price makes a higher high.
MACD makes a lower high.
Price is above EMA (indicating possible exhaustion in bullish trend).
Bullish Divergence:
Price makes a lower low.
MACD makes a higher low.
Price is below EMA (indicating possible exhaustion in bearish trend).
2. EMA Trend Filter
EMA(200) is used as a directional filter:
Bearish divergences considered above EMA (extended bullish conditions).
Bullish divergences considered below EMA (extended bearish conditions).
3. Visual & Alerts
EMA(200) plotted on chart in orange.
Red triangles for Bearish Divergence.
Green triangles for Bullish Divergence.
Alerts fire for both divergence types.
📈 How to Use
Look for divergence signals as potential reversal alerts.
Combine with support/resistance or price action for confirmation.
EMA ensures signals occur in extended zones, increasing reliability.
Recommended Timeframes: 1h, 4h, D.
Markets: Forex, Crypto, Stocks.
⚙️ Inputs
MACD Fast / Slow / Signal Length
EMA Length (default 200)
⚠️ Disclaimer
This script is for educational purposes only. It does not constitute financial advice.
Always test thoroughly before live trading.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.