PROTECTED SOURCE SCRIPT
Diupdate

Trend ZigZag by LANZ

113
🔷 Trend ZigZag by LANZ - is an overlay indicator designed to read market structure through four main modules:

  1. ZigZag legs (visual swing-to-swing path)
  2. Market Structure Ranges (two horizontal “active range” lines built from confirmed pivots, locked until a close breaks them)
  3. MTF Panel (shows “Before / Now / Date” structure states across up to 4 timeframes)
  4. Maker + Fibonacci Swing-to-Swing module (detects the farthest internal swing inside the active range and anchors Fib levels with an optional “discount lock” logic)
  5. It is not a strategy (no orders). Everything is visual + state tracking.


ZigZag module (📉📈 ZigZag)
Goal: Detect swing points and draw legs between them.

Key inputs

Show ZigZag: Turns the ZigZag legs ON/OFF.
TimeFrame (tf): Timeframe used to build the ZigZag.
  • If empty → uses chart timeframe.
  • If set → pivots are built on that resolution and projected on your chart.

Swing High / Low (prd): Sensitivity (min 2).
  • Higher = fewer swings (more smoothing).
  • Lower = more swings (more detail).

Colors / Width / Style: Visual styling of ZigZag legs.

How it works (important behavior)
The script computes pivot candidates using a dynamic window (len) and:
  • Swing High when the current bar is the highest in that window.
  • Swing Low when the current bar is the lowest in that window.

The last pivot can be updated (moved) if price makes a more extreme high/low before a direction flip is confirmed.
✅ This is normal for ZigZag logic.
⚠️ It means the most recent swing can “shift” until confirmed.
What you see on chart
When ON: legs connect the latest swing points.
When OFF: it still draws a dotted last leg (your code intentionally keeps a dotted reference).

Structure module 📉📈
Goal: To define a current active price range and determine whether price movement represents trend continuation or trend reversal.

Key inputs

Enable or disable structure lines.
Show live labels at the right edge of the range.
Control line appearance and how much historical structure remains visible.

How the active range is created:
A new structure range is created only when:
A swing is confirmed and price changes direction.
There is sufficient swing history to define a meaningful range.

Once created:
Two horizontal levels appear:
  • Upper boundary (range high)
  • Lower boundary (range low)

This range becomes active and locked, extending forward in time.
The range remains unchanged until price closes outside one of its boundaries.

How breaks are confirmed:
Only the candle close is considered.
Wicks touching or crossing the level are ignored.

BOS vs ChoCh logic:
Breaks are classified based on the direction of the previous confirmed break:
Upward break:
  • Previous break was upward (or none) → BOS (trend continuation)
  • Previous break was downward → ChoCh (trend change)

Downward break:
  • Previous break was downward (or none) → BOS
  • Previous break was upward → ChoCh


What happens visually on a break:
The boundary that price breaks through is kept and recolored.
The opposite boundary is removed.
A label appears (if enabled):
  • BOS labels are centered within the range.
  • ChoCh labels appear near the start of the range.

Live edge labels are removed to avoid clutter.
The range is released and the system waits for the next structure to form.

Right Tag behavior:
While a range is active:
Each boundary shows a live label indicating what type of event a break would currently produce:
  • “BOS” if it would continue the trend.
  • “ChoCh” if it would reverse the trend.


MTF Panel (⏱️ MTF Panel)
Goal: To provide a multi-timeframe overview of market structure without drawing structure lines on those timeframes.

Panel fields

TF: Timeframe represented:
Before: The previous confirmed structural event.
Now: The current state.
Date: When the current state last changed.

Behavior when no range is active:
Last Event mode: keeps showing the last confirmed BOS or ChoCh.
Waiting mode: displays “Waiting” until a new event appears.

State logic (conceptual):
For each timeframe, the panel evaluates:
Whether price is currently inside an active range.
Whether price has recently confirmed a structural break.
Displayed states include:
  • “Range Bullish”
  • “Range Bearish”
  • “Waiting”
  • The last confirmed BOS or ChoCh


What to expect:
The panel is designed as contextual guidance, not a perfect visual replica of the main chart.
Its purpose is to quickly align or contrast structure across timeframes.

Maker module (🏷️ Maker)
Goal: To identify the most meaningful internal swing that forms inside an active structure range.

Rules applied

Swings that define the range boundaries are excluded.
Only confirmed swings inside the range are considered.
At least two internal swings must exist for a Maker to be valid.

Behavior on structure break:
If price breaks upward:
  • The most extreme internal low is stored.

If price breaks downward:
  • The most extreme internal high is stored.


What you see
If enabled, a “Maker” label appears at the selected internal swing.
These labels are limited to a fixed historical amount to keep the chart clean.

Fibonacci Swing-to-Swing (🧬 Fibonacci) + Discount Lock
Goal: To project contextual Fibonacci levels within an active structure range.

Core concepts

0.0 level:
  • Represents the side of the structure where the break occurred.
  • Can dynamically extend with price if discount lock is enabled.

1.0 level:
Anchored either to:
  • The structure’s change-of-character side, or
  • The Maker from the previous completed range.

If no previous Maker exists, the system automatically falls back to the structure anchor.

Discount Lock behavior:
When enabled:
  • The 0.0 level follows new price extremes.
  • Once price reaches the discount area, the level becomes fixed.

When disabled:
  • The 0.0 level remains fixed from the start.

Discount trigger types
  • Wick-based: activates as soon as price touches the level.
  • Close-based: requires a candle close beyond the level.


Extra Discount levels
Up to four additional Fibonacci levels can be displayed.
These are visual references only and do not affect structure logic.

Limitations and expectations

Swings are dynamic until confirmed; the most recent swing may adjust.
Structural breaks are confirmed only by candle close.
The indicator uses multiple visual elements, but historical objects are capped to maintain performance.
Multi-timeframe states are simplified representations intended for orientation, not exact replication.
Catatan Rilis
UPDATE 💸💸

This update improves both visual clarity and internal consistency of the script. The MTF panel now supports automatic background coloring by event state, making BOS, ChoCh, Range and Waiting conditions easier to identify at a glance. The Maker logic has been strengthened to avoid using stale or invalid Makers: if a completed range does not produce at least two internal confirmed swings, any previous Maker is explicitly cleared, ensuring Fibonacci anchoring in Maker mode is always correct and never inherited incorrectly. Additionally, Maker handling is now fully independent from label visibility, guaranteeing consistent behavior even when visual elements are disabled. Minor visual refinements were applied to Fibonacci labels to improve spacing and readability when multiple levels are displayed simultaneously.

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.