OPEN-SOURCE SCRIPT
Updated

CQ_(L)_Squeeze Momentum Suite Overlay

353
================================================================================
CQ_(L)_SQUEEZE MOMENTUM SUITE OVERLAY
Description and User Manual
================================================================================

--------------------------------------------------------------------------------
1. OVERVIEW
--------------------------------------------------------------------------------

CQ Squeeze Momentum Suite Overlay is an all-in-one price-chart overlay that
combines several classic sub-pane oscillators (Squeeze Momentum, ADX/DMI, an
Expert Trend Locator, a Hull Moving Average, and Momentum divergence
detection) into a single indicator that draws directly on the price chart
instead of a separate panel below it.

Every oscillator-scale value (Momentum, Momentum Strength, Signal, ADX, Key
Level) is mapped onto real price coordinates using a shared "baseline"
reference. This baseline is the single zero-point anchor for all of the
above: when an oscillator crosses zero, its line will touch the baseline
exactly, and the whole visible window of oscillator history is drawn flush
against that same flat, straight reference line.

--------------------------------------------------------------------------------
2. HOW THE OVERLAY MAPPING WORKS
--------------------------------------------------------------------------------

- The script looks back over "Display Length (bars)" candles and finds the
highest high / lowest low in that window.
- Depending on "Placement" (Top or Bottom), the baseline is anchored either
just above the recent highs or just below the recent lows, with some
breathing room controlled by "Vertical Position Adjustment."
- "Height" controls how much vertical price-space the oscillators are
allowed to occupy above/below the baseline.
- All oscillator values are rescaled into that price-space and drawn as
lines/boxes anchored to the baseline, so the whole panel effectively
"floats" over the candles without needing a separate sub-chart.
- Because one single baseline value is used across the entire redrawn
window, the zero-line and every series are always shown as a flat,
straight reference instead of a value that drifts bar-to-bar.
- The redraw happens once per bar-close (snapshot pattern), which keeps the
indicator inside TradingView's per-indicator line/box drawing limits.

--------------------------------------------------------------------------------
3. FEATURE LIST
--------------------------------------------------------------------------------

A) SQUEEZE MOMENTUM
- Momentum oscillator (linear-regression based), selectable moving-average
engine (SMA, EMA, WMA, HMA, DEMA, TEMA, VWMA, ALMA, KAMA, JMA, Zero Lag,
Tillson T3, VIDYA, and more).
- Four render styles: Columns, Histogram, Line, Area.
- Optional Momentum Strength cloud (Momentum minus its own moving-average
Signal line).
- Optional Signal(Momentum) line.
- Multiple color palettes (5 built-in color schemes) reflecting whether
Momentum is positive/negative and rising/falling.
- Optional background tint reflecting the current Momentum color state,
plus a separate "dark mode" gray background option.

B) SQUEEZE PRO DOTS
- Circular markers above price flag when a Bollinger Band / Keltner
Channel squeeze is active, using three intensity levels (Low/Mid/High
squeeze) with distinct colors.
- Only rendered within the "Display Length (bars)" window (see Section 5).

C) ADX WITH KEY LEVEL
- ADX (Average Directional Index) rescaled to sit on the same baseline as
Momentum, so trend strength can be read directly against price.
- A "Key Level" reference line (ADX's neutral/trigger threshold, offset by
the "Distance" input) drawn alongside it.
- Colored Directional Movement Index (DMI): triangle markers below price
mark whether +DI is above or below -DI, colored by trend strength/slope.
- A DMI status label anchored at the baseline explaining, in plain text,
the current trend state (Bullish/Bearish/Weak/No Trend), the ADX value,
whether it is growing or falling, and how many bars since the last DI
cross.
- Bullish/Bearish DMI trend-change alert conditions.

D) EXPERT TREND LOCATOR (XTL)
- A CCI-style trend classifier (traditional or non-traditional formula)
that can recolor the candlesticks themselves (Bull / Bear / Neutral)
based on a configurable threshold.

E) HULL MOVING AVERAGE (HMA)
- Selectable Hull variant: HMA, EHMA, THMA, or Adaptive HMA (AHMA).
- Long/short cross markers (triangle up/down) when the Hull average
changes direction.
- Optional background tint reflecting the Hull trend direction.

F) MOMENTUM DIVERGENCE ENGINE
- Automatic detection of regular and hidden bullish/hidden bearish
divergence between price and the Momentum oscillator.
- Configurable pivot lookback, "2 pivots back" comparison, and a
repaint-safe "delay until candle closes" option.
- Connector lines and "R"/"H" labels drawn at the correct baseline-mapped
price level.
- Alert conditions for all four divergence types.

G) OVERLAY LAYOUT (shared baseline settings)
- Display Length (bars): how many recent bars the baseline / oscillator
mapping and the Squeeze Dots / DMI triangles are drawn across.
- Placement: Top or Bottom of the visible price range.
- Height: how much vertical price-space the oscillators occupy.
- Vertical Position Adjustment: padding between the baseline and the
actual candle range.

--------------------------------------------------------------------------------
4. INPUT REFERENCE (BY GROUP)
--------------------------------------------------------------------------------

SQUEEZE MOMENTUM
Show Momentum - toggles the Momentum plot.
Color Format - selects one of 5 color palettes (1-5).
Background Off - disables the Momentum-colored background tint.
Momentum Style - Area / Columns / Histogram / Line.
Show Signal - toggles the Signal(Momentum) line.
Show Strength (MOM) - toggles the Momentum Strength cloud/line.
Draw Divergence - master toggle for the divergence engine.
Gray Background for Dark Mode - alternate gray background tint.
Show Squeeze PRO [SQZ] - toggles the Squeeze dots.
Show SQZ Zero Line - draws the flat baseline/zero reference line.

ADX
Show ADX with KeyLevel - toggles ADX + Key Level lines.
Scale for ADX - divisor used to rescale ADX into Momentum units.
Positive/Negative slope colors - ADX line color when rising/falling.
KeyLevel with color - colors the Key Level line by DMI trend instead
of the ADX slope color.
Distance between KeyLevel and 0 - offsets the Key Level line from zero.
Display the colored DMI triangles - toggles the +DI/-DI triangle markers.
Hide DMI Label - hides the plain-text DMI status label.
DMI Label Text Size - Auto/Tiny/Small/Normal/Large/Huge.

(unnamed group, XTL bar coloring)
Use XTL Bars Color - recolors candles per the XTL trend state.
XTL: Trend Up / Neutral / Trend Down - colors for each XTL state.

HULL MOVING AVERAGE
Show (Hull Moving Average) Signal - toggles Hull cross markers.
Background - toggles the Hull-trend background tint.

OVERLAY LAYOUT
Display Length (bars) - lookback window for the baseline mapping AND
the Squeeze Dots / DMI triangle visibility.
Placement - Top or Bottom anchor for the baseline.
Height - vertical space (in "notches") given to the
oscillators.
Vertical Position Adjustment - padding between the baseline and the
recent price range.

SQUEEZE MOMENTUM INDICATOR PARAMETERS (SQZMOM)
MOM Length / Source / Type - Momentum calculation length, price source,
and moving-average engine.
Signal Length - smoothing length for Signal(Momentum).
Squeeze Length / Source - length and source used for the Bollinger Band
/ Keltner Channel squeeze detection.
BB Calculation Type / MultFactor - Bollinger Band moving-average type and
standard-deviation multiplier.
Keltner Channel Calculation Type / Use TrueRange - Keltner Channel
moving-average type and range source.

DIRECTIONAL MOVEMENT INDEX (Colored DMI)
Alert: Bullish/Bearish Trend - enable/disable DMI trend-change alerts.
ADX Smoothing / DI Length - standard ADX/DMI calculation lengths.
Key level for ADX - the ADX threshold considered "trending."
Weak Trend Threshold - the ADX threshold below which trend is
considered absent.
Historical Label Readings - shows the DMI label's reading from N bars
back instead of the current bar.

EXPERT TREND LOCATOR (XTL)
Length / Type / Source - CCI-style calculation length, moving-average
type, and price source.
Threshold Level - the +/- CCI threshold that defines Bull/Bear.
Use the traditional CCI formula - switches between the classic and
non-traditional CCI denominator.

HULL MOVING AVERAGE (HMA)
Length / Type / Source - Hull average length, variant, and price
source.

DIVERGENCES FOR MOMENTUM
Plot Bullish / Hidden Bullish / Bearish / Hidden Bearish - toggle each
divergence type independently.
Delay plot until candle is closed - avoids repainting divergence signals.
Lookback 2 Pivots? - also compares against the pivot two bars back.
Pivot Lookback Right/Left - pivot-detection window.
Min/Max of Lookback Range - how far back (in bars) a divergence pair may
span to still be considered valid.

--------------------------------------------------------------------------------
5. NOTES ON THE "DISPLAY LENGTH (BARS)" SETTING
--------------------------------------------------------------------------------

"Display Length (bars)" (in the Overlay Layout group) controls THREE things
at once:

1. How many historical bars the baseline/oscillator snapshot engine
redraws (Momentum, Strength, Signal, ADX, Key Level, Zero Line).
2. How many recent bars show Squeeze PRO dots above price.
3. How many recent bars show the colored DMI triangles below price.

Anything older than this window is simply not drawn, keeping the chart
readable and staying within TradingView's per-indicator object limits
(500 lines / 500 boxes / 50 labels). Increasing this value shows more
history but uses more of that budget; the input is capped at 100 bars to
leave headroom for all series that can be active simultaneously.

--------------------------------------------------------------------------------
6. ALERTS
--------------------------------------------------------------------------------

- DMI Bullish Trend / DMI Bearish Trend (on trend-state change)
- Regular Bull Divergence / Hidden Bull Divergence
- Regular Bear Divergence / Hidden Bear Divergence

--------------------------------------------------------------------------------
7. QUICK START
--------------------------------------------------------------------------------

1. Add the indicator to a price chart (it renders as an overlay, not a
separate pane).
2. In "Overlay Layout," set Display Length to match how much recent price
history you want the oscillators plotted against, and adjust
Placement/Height/Vertical Position Adjustment until the oscillator
band sits where you want it relative to candles.
3. Enable/disable Momentum, Strength, Signal, ADX, Squeeze Dots, DMI
triangles, and Divergences as needed under their respective groups.
4. Use "Show SQZ Zero Line" if you want an explicit flat reference line
at the baseline.
5. Set up alerts from the DMI or Divergence alert conditions if you want
notifications outside of TradingView.

================================================================================
End of manual.
================================================================================
Release Notes
Added fine tunning adjustment of divergence markers position.

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.