OPEN-SOURCE SCRIPT

SMT w Alerts

329
This script is a Smart Money Tool (SMT) Divergence Indicator written in TradingView's Pine Script v6. It automatically detects and visualizes instances where highly correlated assets (like NQ, ES, and YM) fall out of sync at major price swings.

Here is a breakdown of how the script works and its key features:

1. Core Logic (Pivot Tracking)
The script uses ta.pivothigh and ta.pivotlow to identify swing highs and swing lows on your main chart based on a window of bars (default 3 bars left and right). It remembers the most recent pivot and the one right before it so it can compare the two.

2. Dual-Symbol Comparison
When a pivot is confirmed on your main chart, the script immediately looks at the price action of two comparison symbols (e.g., MNQ and MES) at that exact same time.

Tolerance Window: Because assets like NQ and ES don't always peak on the exact same 1-minute or 5-minute candle, the script includes a "Comparison Tolerance" input. It looks a few bars before and after the pivot on the comparison symbols to find their true peak/valley.

3. Divergence Detection
The script compares the slope of the pivots on your chart against the comparison symbols:

Bearish SMT (Highs): If your chart makes a Higher High, but the comparison symbol makes a Lower High (or vice versa). This indicates underlying weakness in the buying pressure.

Bullish SMT (Lows): If your chart makes a Lower Low, but the comparison symbol makes a Higher Low (or vice versa). This indicates underlying strength in the selling absorption.

It checks both comparison symbols simultaneously — if an SMT forms against either of them, it triggers the signal.

4. Visuals & Aesthetics
The SMT Bracket: When an SMT is detected, it draws a clean bracket (or "bridge") connecting the two diverging pivots. It draws horizontal tick marks at the pivots, vertical lines extending outward, and a horizontal bridge connecting them with a small "SMT" label. The bracket dynamically sizes itself using ATR (Average True Range).

Unused Pivots: Pivots that do not result in an SMT divergence are optionally connected with subtle grey dashed lines so you can see the market structure.

Bar Coloring: The candle where the SMT is officially confirmed is highlighted with a subtle background color.

5. Dashboard & Alerts
Dashboard: A clean table in the top right corner tracks how many Bearish and Bullish SMTs have occurred on the chart, and how many bars ago the most recent one fired.
Alerts: The script exposes alert conditions (alertcondition) that you can hook into TradingView's alert system to receive notifications when a Bullish or Bearish SMT forms.

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.