Skip to content

SMT Divergences -- Indicator Contract

Identity

Field Value
Pine Title "SMT Divergences"
Short Title "SMT"
Study Filter "SMT Divergences"
Overlay true
Timeframe Any

Visual Channels

Channel Signal Role Required for Strategy
Lines Primary -- divergence lines connecting pivot points Yes
Labels Primary -- divergence type and paired instrument identification Yes

SMT Divergences uses only two visual channels. Both carry essential signal data.


Lines -- Divergence Lines

Each SMT divergence is drawn as a line connecting two pivot points on the chart.

Bullish SMT

A bullish SMT occurs when the current instrument makes a lower low but the paired instrument makes a higher low (divergence at lows).

Property Value
Color bullColor (default: black)
Width bullWidth (configurable)
Style bullStyle (configurable: Solid/Dashed/Dotted)
Start point First pivot low (x1, y1)
End point Second pivot low (x2, y2), where y2 < y1 (lower low on current instrument)

Bearish SMT

A bearish SMT occurs when the current instrument makes a higher high but the paired instrument makes a lower high (divergence at highs).

Property Value
Color bearColor (default: black)
Width bearWidth (configurable)
Style bearStyle (configurable: Solid/Dashed/Dotted)
Start point First pivot high (x1, y1)
End point Second pivot high (x2, y2), where y2 > y1 (higher high on current instrument)

Line Interpretation

The slope of the line combined with the label style determines the divergence type:

  • Line connecting two lows with a downward slope on the current instrument + label_up = Bullish SMT
  • Line connecting two highs with an upward slope on the current instrument + label_down = Bearish SMT

Labels

Label Properties

Property Value
Text "SMT - {tickerName}" where {tickerName} is the paired instrument
Position Midpoint of the divergence line
Color labelColor (default: black)
Size labelSize (configurable)

Label Style Encoding

Style Meaning
label.style_label_up Bullish SMT -- divergence at lows, expect price to rise
label.style_label_down Bearish SMT -- divergence at highs, expect price to fall

Label Text Pattern

"SMT - {tickerName}"

Examples:

  • "SMT - ES" -- divergence detected against ES (when charting NQ)
  • "SMT - NQ" -- divergence detected against NQ (when charting ES)
  • "SMT - ETH" -- divergence detected against ETH (when charting BTC)

The tickerName in the label identifies which instrument was used for comparison.


Auto-Pairing

The indicator automatically pairs correlated instruments. When one is charted, the other is used for divergence comparison.

Pair Instrument A Instrument B
Index Futures NQ (Nasdaq) ES (S&P 500)
Crypto BTC (Bitcoin) ETH (Ethereum)
Metals GC (Gold) SI (Silver)
Energy CL (Crude Oil) RB (RBOB Gasoline)

If the charted instrument does not match any auto-pair, the user can specify a manual ticker input for comparison.

Pairing Direction

The label text always shows the paired instrument (not the charted one). So if you are on an NQ chart and see "SMT - ES", the divergence was detected between NQ (charted) and ES (paired).


Breakage Detection

An SMT divergence can be broken (invalidated) after it forms.

Bullish SMT Breakage

A bullish SMT is broken when price drops below the SMT's price level (the lower low that formed the divergence).

Bearish SMT Breakage

A bearish SMT is broken when price rises above the SMT's price level (the higher high that formed the divergence).

Visual Behavior on Breakage

delBroken Setting Behavior
Enabled (default) Broken SMT's line and label are deleted from the chart
Disabled Broken SMT's line and label remain on the chart

Snapshot Implications

When delBroken is enabled, the interpreter will never see broken SMTs -- they are removed before the snapshot is taken. This means all visible SMTs are unbroken (valid). When delBroken is disabled, the interpreter must determine breakage by checking if price has violated the SMT's level.


State Derivation

SMT Divergences does not have a traditional state machine. Instead, the strategy state is derived from the set of currently visible elements on the chart.

Algorithm

  1. Collect all SMT labels visible on the chart (filtered by study_filter "SMT Divergences").
  2. For each label, determine:
    • Direction: label_up = bullish, label_down = bearish
    • Paired instrument: parse from label text ("SMT - {ticker}")
    • Price level: label y-position (midpoint of the divergence)
    • Time: label x-position (midpoint of the divergence line)
  3. Sort by time (most recent last).
  4. Filter (if delBroken is disabled):
    • For bullish SMTs: broken if current price < associated line's lower y-value
    • For bearish SMTs: broken if current price > associated line's upper y-value
    • Remove broken SMTs from consideration
  5. Most recent unbroken SMT = the active signal.

Resulting States

Condition State Strategy Implication
No SMT labels visible NO_SMT No divergence signal. Neutral.
Most recent is bullish (label_up) BULLISH_SMT Expect price reversal upward. Supports long bias.
Most recent is bearish (label_down) BEARISH_SMT Expect price reversal downward. Supports short bias.
Multiple SMTs, mixed directions Use most recent Older signals are superseded by newer ones.

Parser Rules

# Channel Identifier Meaning Parser Logic
1 Label text matches "SMT - .+", style == label_up Bullish SMT signal Parse paired ticker from text. y-position = signal price level.
2 Label text matches "SMT - .+", style == label_down Bearish SMT signal Parse paired ticker from text. y-position = signal price level.
3 Line color == bullColor, connects two lows Bullish divergence line Start and end y-values define the divergence range. Lower y = breakage level.
4 Line color == bearColor, connects two highs Bearish divergence line Start and end y-values define the divergence range. Higher y = breakage level.
5 Label Absent (deleted) Broken SMT (when delBroken enabled) If previously seen, now gone = broken and invalidated.
6 Line Absent (deleted) Broken SMT line (when delBroken enabled) Accompanies label deletion.

Associating Lines with Labels

Each SMT event produces exactly one line and one label. To associate them:

  1. The label is positioned at the midpoint of the line (both x and y).
  2. The label's x-position falls between the line's x1 and x2.
  3. The label's y-position is approximately (line.y1 + line.y2) / 2.
  4. The label text ("SMT - {ticker}") and style (label_up/label_down) match the line's color (bullColor/bearColor).

In practice, iterating labels is sufficient for state derivation. Lines provide additional precision (exact pivot prices) when needed for breakage detection.


Edge Cases

Case Handling
Multiple SMTs visible simultaneously Normal. Multiple divergences can exist at different times and price levels. Strategy uses the most recent unbroken one.
Bullish and bearish SMTs both active Conflicting signals. Most recent takes precedence. If they formed at the same time (rare), no clear signal -- treat as neutral.
delBroken disabled and many old SMTs remain Filter by time relevance. Only consider SMTs from the current or recent sessions. Check breakage status for each.
Same-color lines for bull and bear (both default black) Cannot distinguish by color alone. Must use label style (label_up vs label_down) as the primary discriminator.
Paired instrument data unavailable Indicator will not produce SMT signals. No labels or lines will appear. State = NO_SMT.
Manual ticker input (non-auto-pair) Label text will show whatever ticker the user configured. Parse the same way.
SMT on very old bar (off visible chart area) MCP only returns visible elements. Old SMTs scrolled off-screen are not in the snapshot. This is acceptable -- stale signals are not relevant.
Line and label count mismatch Should not occur in normal operation. If it does, trust labels for state derivation (they are the primary signal carrier).
Multiple SMTs from different pairs on same chart Unlikely (indicator is configured for one pair at a time). If it occurs, all labels will reference the same paired ticker.