OPEN-SOURCE SCRIPT
Updated

HH/HL/LH/LL Structure Tracker [AGPro Series]

1 393
HH/HL/LH/LL Structure Tracker [AGPro Series]

🔹 Overview

HH/HL/LH/LL Structure Tracker automatically classifies every confirmed swing on your chart using pure Dow Theory — the original price-action framework that precedes and underlies every modern market-structure methodology. Each pivot high is labeled as a Higher High (HH) or Lower High (LH), and each pivot low as a Higher Low (HL) or Lower Low (LL). The sequence of the last four swings derives a live trend state: Bullish, Bearish, or Ranging.

No oscillators. No lagging averages. Just the raw geometry of price.


💎 What Makes This Different

While most "market structure" indicators focus on Break-of-Structure or Change-of-Character logic layered with Smart Money terminology, this script returns to the foundation: the four-swing classification that Charles Dow documented over a century ago. The result is an uncluttered, universally readable overlay that communicates structural context at a glance — regardless of which higher-level methodology you apply next (SMC, Wyckoff, Elliott, or classical technical analysis).

Key differentiators versus generic HH/HL scripts on the public library:

• Live structure range zone that dynamically recolors with the trend state (bullish teal, bearish pink, ranging amber).
• Bull Streak and Bear Streak counters — a quantifiable measure of trend persistence (e.g. "3 consecutive HH-HL swings").
• Semantic break classification: the panel distinguishes a continuation break (HH or LL broken in trend direction) from a reversal break (LH or HL broken against the prior structure).
• Progressive label offset algorithm: when several same-type swings cluster without an intervening opposite swing, each subsequent label is offset further from price, eliminating the overlap that plagues most swing scripts on fast-moving charts.
• AGPro design language: premium info panel, adjustable font size and theme, and a disciplined color palette.


🧠 Methodology

1. Pivot detection. A confirmed swing high is a bar whose high exceeds the preceding and following N bars (N = Pivot Length, default 5). Confirmed swing lows mirror the rule. Confirmation occurs N bars after the pivot bar, never repaints.

2. Swing classification. Each new confirmed high is compared to the previous confirmed high. If greater, it is HH; if lesser, LH. Lows are compared to the previous low: greater means HL, lesser means LL.

3. Trend derivation. If the most recent high is HH and the most recent low is HL, the trend state is Bullish. If LH and LL, Bearish. Any mixed sequence (HH + LL, LH + HL) returns Ranging.

4. Structure range zone. A rectangle is drawn between the most recent swing high and most recent swing low. The zone is always current: as new swings confirm, the zone updates in place. Zone color tracks the trend state.

5. Structure break. A close above the most recent swing high (or below the most recent swing low) fires a break event. The type of swing broken is reported — breaking an LH or HL typically precedes a trend reversal; breaking an HH or LL typically signals continuation.


📊 Signals & Alerts

Three optional alert types are available, each using "once per bar close" frequency to prevent intrabar noise:

• New Higher High confirmed — fires when a fresh HH is classified.
• New Lower Low confirmed — fires when a fresh LL is classified.
• Structure break — fires on a close outside the current structure range, labeled as either (reversal signal) or (continuation).

The live info panel reports: Trend state, Bull Streak, Bear Streak, Last High (with type and price), and Last Break (with type and price).


⚙️ Key Inputs

• Pivot Length — sensitivity of swing detection (2 to 50). Lower values capture minor structure; higher values isolate major swings only. Typical: 3–8 intraday, 5–15 swing trading.
• Max Visible Labels — caps the number of historical labels kept on the chart to preserve a premium uncluttered look.
• Label & Panel Font Size — five sizes from Tiny to Huge, default Normal.
• Label Distance from Price (ATR) — base vertical offset of labels from pivot candles.
• Structure Range Zone — toggle, transparency, and border.
• Trend Background Tint — subtle bullish or bearish chart shading.
• Info Panel — toggle, location (six positions), and theme (Dark or Light).
• Alerts — independent toggles for new HH, new LL, and structure break.


🎯 How to Use

Context tool, not a standalone signal generator. Use the trend state to filter entries from your primary methodology: take long setups only while Trend is Bullish and Bull Streak is building, or vice versa. The structure range zone highlights the active battleground between buyers and sellers — trades taken inside the zone are counter-trend by definition, trades taken on a decisive break of the zone align with the emerging new trend.

Reversal breaks (LH or HL broken) are high-information events — they are often the first objective signal that a prevailing trend is losing conviction, ahead of any moving-average cross or momentum divergence. Continuation breaks (HH or LL broken) are confirmation events that validate staying with the trend.

Works on all markets and all timeframes. Particularly effective on liquid instruments with clear structural rhythm: major crypto pairs, FX majors, index futures, and large-cap equities.


⚠️ Limitations & Transparency

• Pivot confirmation requires N bars after the swing; the most recent unconfirmed swing is never labeled.
• In low-volatility sideways regimes, pivot clustering is inevitable — the Pivot Length input should be raised to filter noise on ranging charts.
• The trend state is derived from only the last two swings; it does not account for higher-timeframe context. Pair with a higher-timeframe version of the same script for multi-timeframe confluence.
• Does not provide entry, stop, or target levels. It is a structural framework, not a complete trading system.


📌 Risk Disclosure

This indicator is for educational and analytical purposes only. It does not constitute financial advice, a trading recommendation, or a guarantee of future performance. All trading involves risk of loss. Past structural patterns do not guarantee future outcomes. Always conduct your own due diligence and use appropriate risk management.
Release Notes
🔧 UPDATE NOTES - V1.3

This update focuses on readability, structure, chart clarity, and usability.

The core purpose of the script remains unchanged.
This release improves how the existing HH/HL/LH/LL market structure logic is presented, organized, and interpreted on the chart.

This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.


------------------------
What Changed
------------------------

• Rebuilt the source header and naming structure.
The public script title now follows the current AGPro Series format while the panel title keeps the AG Pro brand presentation.

• Refined the Dow Theory structure model presentation.
The script still classifies confirmed swings as HH, HL, LH, and LL, but the visual output is now cleaner and easier to read.

• Added a clearer structure score.
The panel now summarizes recent swing alignment with a 0-100 structure score.

• Improved structure range zone design.
The active range between the latest confirmed swing high and swing low now includes centered zone text for state, trend, and score.

• Rebuilt the panel lifecycle.
The panel uses the required single merged blue header row and avoids clearing the header row during normal updates.


------------------------
Visual Improvements
------------------------

• Improved chart readability by adjusting swing labels, break labels, connector lines, and zone spacing.

• Reduced visual clutter by adding label density control and bounded label retention.

• Refined visual hierarchy so current structure state, active range, and confirmed swings stand out more clearly.

• Adjusted label positioning to avoid overlap with candles and to keep swing labels readable.

• Reduced default label density so the publication view shows a cleaner structure map instead of printing every minor pivot.

• Disabled break labels by default because the panel already reports the latest structure break.


------------------------
Interface & Usability
------------------------

• Optimized panel layout for clearer information flow.

• Added configurable label density, label font size, panel font size, panel position, and panel theme controls.

• Kept the summary panel enabled by default for immediate context.

• Enhanced overall user experience without changing the core HH/HL/LH/LL logic.


------------------------
Behavior Notes
------------------------

This update does not change the core analytical purpose of the script.

The goal is to improve clarity and usability, not to introduce predictive behavior.

Users should interpret outputs the same way as before, but with improved visual structure.


------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, timeframe differences, and pivot confirmation delay may affect how swing labels and structure zones appear.

Outputs should always be interpreted within broader market context.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.

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.