PROTECTED SOURCE SCRIPT
Mis à jour

TRharmonic ZigZag

66
TRharmonic Multi-ZigZag — 3-Layer Structure Detector


TRharmonic Multi-ZigZag is a professional-grade recursive zigzag indicator that reveals market structure across three hierarchical layers simultaneously. Unlike traditional single-depth zigzag tools, this indicator builds each layer from the structural pivots of the layer below — capturing both micro price action and macro trend direction in a unified view.

🔹 How It Works

The indicator operates on three recursive levels:

Level 0 (Fast) — Detects base-level swing highs and lows using a configurable lookback window. This layer captures the finest price structure and reacts quickly to new pivots.

Level 1 (Medium) — Automatically derived from Level 0's significant pivots (Higher Highs and Lower Lows). Filters out noise and reveals intermediate market structure.

Level 2 (Trend) — Built from Level 1's structural breakouts, showing only the dominant trend-level swings. This is the "big picture" layer.

Each higher level inherits only the most significant pivots from the level below — HH (Higher High) and LL (Lower Low) pivots propagate upward, while LH (Lower High) and HL (Higher Low) pivots are buffered and only promoted when structurally necessary.

🔹 Pivot Classification

Every pivot is automatically classified into one of four categories:

HH (Higher High) — Price made a new high above the previous high → Bullish continuation
LL (Lower Low) — Price made a new low below the previous low → Bearish continuation
LH (Lower High) — Price failed to exceed the previous high → Potential weakness
HL (Higher Low) — Price held above the previous low → Potential strength
These labels appear directly on the chart with color-coded markers for instant visual recognition.

🔹 Key Features

✅ 3 recursive zigzag layers with independent depth settings
✅ Real-time HH/HL/LH/LL classification on every pivot
✅ Fully customizable colors, line widths, and label visibility per layer
✅ Toggle each layer on/off independently
✅ Professional stats table showing pivot count, last direction, and price per layer
✅ Zero-lag design — no repainting on confirmed bars
✅ Works on all instruments and timeframes (5min+)

🔹 Use Cases

Trend Identification: Level 2 shows the dominant trend; consecutive HH+HL = uptrend, LH+LL = downtrend
Structure Break Detection: When Level 1 prints an LL after a series of HH = potential trend reversal
Multi-Timeframe in Single Chart: Three structural layers eliminate the need to switch between timeframes



🔹 Settings

Parameter Default Description
Fast Depth 7 Level 0 lookback — more pivots, faster reaction
Medium Depth 13 Level 1 — standard market structures
Trend Depth 34 Level 2 — major trend waves only
Max Pivots 200 Maximum stored pivots per level
🔹 Recommended Approach

Start with default settings. Use Level 0 for scalping entries, Level 1 for swing trade structure, and Level 2 for trend direction bias. When all three levels align (e.g., all showing HH), you have strong trend confluence.

⚠️ This indicator is a structural analysis tool. It does not generate buy/sell signals. Always combine with your own analysis and risk management.

Notes de version
Added MAX_LOOKBACK constraint to prevent historical buffer overflow errors when accessing pivots beyond the 5000-bar limit

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.