OPEN-SOURCE SCRIPT
Smart Divergence [Reason Edition]

Stop trading divergences "in thin air". Start trading structural confluence.
Most divergence indicators fail for one reason: they signal reversals based solely on oscillator math (RSI vs. Price), ignoring the chart's structure. This leads to costly entries against strong trends.
Smart Divergence [Reason Edition] solves this by applying an Institutional Context Filter. It does not simply alert you of a divergence; it validates the signal against key market structures ("Walls") and—crucially—tells you exactly why the signal appeared directly on the label.
🚀 How It Works: The "Smart Filter" Logic
This script operates on a strict rule: "No Structure, No Signal."
For a Bullish or Bearish divergence to be valid, price must not only diverge from RSI but also physically touch or react to one of four key structural levels:
BB (Bollinger Bands): Rejection due to volatility extension (2.0 StdDev).
KC (Keltner Channels): Rejection due to average range deviation (1.5 ATR).
Pivots (S1/R1): Rejection at standard daily algorithmic levels.
VWAP: Rejection at the institutional average price (Volume Weighted Average Price).
🏷️ Dynamic "Reason" Labels
This is the core feature of this edition. The label on your chart adapts dynamically to show the specific confluence behind the trade.
Examples you will see:
SMART BULL (BB) → The divergence is valid because price hit the Bollinger Band.
SMART BULL (VWAP) → The divergence is valid because price bounced off the VWAP.
SMART BULL (BB VWAP) → High Probability: Price hit the Bollinger Band AND the VWAP simultaneously.
The Logic: The more "Reasons" (acronyms) appear inside the label, the stronger the structural wall, and the higher the probability of a reversal.
🛠️ Settings & Features
🛡️ Smart Filter (Toggle):
ON (Default): Only shows high-quality signals that occur at Support/Resistance zones.
OFF: Shows all raw technical divergences (standard mode).
Alerts Included: Setup custom alerts for "Smart Bull" (Buys) and "Smart Bear" (Sells).
Zero Repainting: Signals are confirmed upon candle close/pivot confirmation.
📋 How to Trade It
Wait for the Label: Do not guess. Wait for the SMART label to appear.
Check the Reason: Look at the text in parenthesis (...).
Single reason (e.g., KC) is a valid setup.
Cluster reasons (e.g., BB S1 VWAP) represent a "Concrete Wall" and are ideal for aggressive entries.
Context: Works best on Intraday timeframes (1m, 5m, 15m) for scalping, and Daily timeframe for Swing Trading bottoms/tops.
Disclaimer: This tool is for educational purposes and technical analysis assistance. Past performance does not guarantee future results. Manage your risk.
Most divergence indicators fail for one reason: they signal reversals based solely on oscillator math (RSI vs. Price), ignoring the chart's structure. This leads to costly entries against strong trends.
Smart Divergence [Reason Edition] solves this by applying an Institutional Context Filter. It does not simply alert you of a divergence; it validates the signal against key market structures ("Walls") and—crucially—tells you exactly why the signal appeared directly on the label.
🚀 How It Works: The "Smart Filter" Logic
This script operates on a strict rule: "No Structure, No Signal."
For a Bullish or Bearish divergence to be valid, price must not only diverge from RSI but also physically touch or react to one of four key structural levels:
BB (Bollinger Bands): Rejection due to volatility extension (2.0 StdDev).
KC (Keltner Channels): Rejection due to average range deviation (1.5 ATR).
Pivots (S1/R1): Rejection at standard daily algorithmic levels.
VWAP: Rejection at the institutional average price (Volume Weighted Average Price).
🏷️ Dynamic "Reason" Labels
This is the core feature of this edition. The label on your chart adapts dynamically to show the specific confluence behind the trade.
Examples you will see:
SMART BULL (BB) → The divergence is valid because price hit the Bollinger Band.
SMART BULL (VWAP) → The divergence is valid because price bounced off the VWAP.
SMART BULL (BB VWAP) → High Probability: Price hit the Bollinger Band AND the VWAP simultaneously.
The Logic: The more "Reasons" (acronyms) appear inside the label, the stronger the structural wall, and the higher the probability of a reversal.
🛠️ Settings & Features
🛡️ Smart Filter (Toggle):
ON (Default): Only shows high-quality signals that occur at Support/Resistance zones.
OFF: Shows all raw technical divergences (standard mode).
Alerts Included: Setup custom alerts for "Smart Bull" (Buys) and "Smart Bear" (Sells).
Zero Repainting: Signals are confirmed upon candle close/pivot confirmation.
📋 How to Trade It
Wait for the Label: Do not guess. Wait for the SMART label to appear.
Check the Reason: Look at the text in parenthesis (...).
Single reason (e.g., KC) is a valid setup.
Cluster reasons (e.g., BB S1 VWAP) represent a "Concrete Wall" and are ideal for aggressive entries.
Context: Works best on Intraday timeframes (1m, 5m, 15m) for scalping, and Daily timeframe for Swing Trading bottoms/tops.
Disclaimer: This tool is for educational purposes and technical analysis assistance. Past performance does not guarantee future results. Manage your risk.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.