OPEN-SOURCE SCRIPT

SMT Divergence Matrix [JOAT]

1 359
════════════════════════════════
SMT DIVERGENCE MATRIX [JOAT]
════════════════════════════════

Smart Money Technique divergence, automated. This tool watches your chart symbol against up to two correlated reference assets and flags the moment they disagree at a swing — the classic footprint of one market failing to confirm another. When your chart carves a new low that a correlated market refuses to match, that non-confirmation is highlighted as a potential turn.

Snapshot

▎ WHAT IT DOES
It compares swing highs and lows on your chart to the same swings on two reference instruments and looks for SMT divergence — where the assets normally move together but split at a pivot. Each qualifying event is drawn as a connector line between the two chart pivots, tagged with a BUY or SELL pill, and paired with an optional ATR-based stop and target zone. A dashboard reports live correlation, structure, and which reference triggered.

▎ HOW IT WORKS
Swing detection — confirmed pivot highs and lows are located on the chart using a configurable left/right pivot length. Larger values isolate more significant swings.
Reference sync — the same high/low/close series are pulled for up to two reference assets on your chart's timeframe, guarded against invalid symbols.
Bullish SMT — the chart prints a lower low while a correlated reference prints a higher low. That failure to confirm the downside is read as bullish non-confirmation.
Bearish SMT — the chart prints a higher high while a correlated reference prints a lower high, reading as bearish non-confirmation.
Either reference can trigger — a signal fires from whichever asset fails to confirm; the dashboard shows REF1, REF2, or both.
Correlation filter — rolling correlation between chart and reference is measured over a lookback. SMT only makes sense when assets normally track together, so signals can be restricted to references whose correlation is currently at or above a minimum.
Confirmation filter — the triggering bar can be gated by RSI momentum turning in the signal direction, by a directional candle close, by both, or by nothing.
Cooldown — a minimum bar gap between same-direction signals prevents clustering, and the engine never fires a buy and sell on the same bar.
Trade zones — on each signal, entry is taken at the close, stop is placed a chosen ATR multiple away, and the target is projected at your risk/reward ratio. The zones live-extend to the right each bar and freeze the moment price touches the stop or target.

▎ HOW TO USE IT
• Set Reference Asset 1 and 2 to instruments that genuinely correlate with your chart (index futures, sector peers, a lead/lag pair). The technique is only meaningful when the assets normally move together.
• A BUY pill below price marks bullish non-confirmation; a SELL pill above price marks bearish non-confirmation. The pill text names the reference that triggered.
• The divergence line connects the two chart pivots involved, so you can see the exact swings being compared.
• Treat the red zone as risk (entry-to-stop) and the blue/violet zone as reward (entry-to-target). Use them as a visual framework, not a mechanical order.
• Combine signals with your own read of market structure, session timing, and key levels rather than trading them in isolation.

▎ KEY SETTINGS
Engine — swing pivot length, the two reference symbols and their enable toggles, and correlation lookback.
Filters — confirmation mode (None / RSI / Candle / Both), RSI length, positive-correlation requirement with a minimum threshold, and signal cooldown.
Trade Model — show ATR SL/TP toggle, ATR length, stop distance in ATR multiples, risk/reward target, and a cap on drawn setups for performance.
Visuals — divergence lines, signal labels, pivot markers, label size, custom bull/bear colors, an optional candle zone-reader, and a session VWAP with ±σ bands.
Dashboard — show toggle, position, and text size.

▎ DASHBOARD
The panel reports correlation state and value for each reference (Strong+, Positive, Weak, Negative, Strong−, or OFF), the last SMT side with the triggering reference, current market structure (HH / HL / LH / LL), running bull/bear counts, total divergences, live signal status, and current ATR.

▎ ALERTS
Bullish SMT — chart lower low versus a correlated higher low.
Bearish SMT — chart higher high versus a correlated lower high.
Both include ticker and interval placeholders in the message.

▎ NOTES
• Works on any symbol and any timeframe; references are read on the chart's own timeframe.
• Signals are based on confirmed pivots, which require the configured right-side bars to close before a swing is validated.
• Colored candles and VWAP bands are off by default for a clean chart, and the drawn-setup cap keeps performance stable.
• Reference data uses non-lookahead requests and tolerates invalid symbols without breaking the script.

For research and education only. This is not financial advice. No indicator predicts the future, on-chart signals and counts are illustrative of historical behavior only, and past behavior does not guarantee future results. Always manage your own risk.

Made with passion by JackOfAllTrades ⚡

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.