Cody Zig ZagCody Zig Zag Indicator - Complete Explanation
This is a Zig Zag indicator that replicates the MetaTrader 4 (MT4) version, which works differently than TradingView's built-in Zig Zag. Here's what it does:
🎯 What is a Zig Zag Indicator?
It filters out minor price movements to show only significant swing highs and swing lows, helping you identify trends and chart patterns (head & shoulders, double tops/bottoms, etc.).
⚙️ User Settings (Inputs)
Setting Default What It Does
Depth 6 Lookback period to find local highs/lows
Deviation 5 Minimum price change (in ticks) to form a new swing point
Backstep 2 Minimum bars between swing points
Line Thickness 2 Zig Zag line width
Bull Color Lime Color for upward moves
Bear Color Red Color for downward moves
Repaint Levels true If ON, lines/labels adjust real-time; if OFF, they lock on close
🔍 How It Works (The "Bake" Section)
Step 1: Find Potential Pivot Points
p_lw = Most recent low within Depth bars
p_hg = Most recent high within Depth bars
Checks if price moved enough (Deviation * tick size) to qualify
Step 2: Determine Direction
down = Boolean (true = bearish/downward leg, false = bullish/upward leg)
Tracks whether we're connecting a high→low (down) or low→high (up)
Step 3: Draw Zig Zag Lines
Connects alternating swing highs and swing lows
Labels each point as:
HH = Higher High
LH = Lower High
LL = Lower Low
HL = Higher Low
🏷️ Labels Explained
When price makes a new swing point, you'll see:
HH (Higher High) - Bullish continuation signal
LH (Lower High) - Bearish reversal signal
LL (Lower Low) - Bearish continuation signal
HL (Higher Low) - Bullish reversal signal
📊 Visual Features
Colored Zig Zag lines: Green for up-legs, Red for down-legs
Background color: Green during bullish legs, Red during bearish legs (90% transparent)
Labels: Tiny triangles pointing up/down with text
⚠️ Repaint Behavior (Important!)
Repaint = ON (default) Repaint = OFF
Lines/labels update in real-time Locks on bar close
Can "repaint" history More reliable for backtesting
Good for real-time trading No historical repainting
Warning: Zig Zag indicators naturally repaint because they need future bars to confirm pivot points. The repaint option controls HOW they repaint.
🚨 Alerts
This script triggers alerts when:
Direction Changed - Zig Zag switches from up to down or down to up
Bullish Direction - Switches from down to up
Bearish Direction - Switches from up to down
📈 How to Use
Identify Trend: Upward Zig Zag = Uptrend; Downward = Downtrend
Find Patterns: Look for HH/HL patterns (bullish) or LH/LL patterns (bearish)
Divergence: Compare Zig Zag swings with oscillator indicators
Support/Resistance: Swing points act as natural S/R levels
⚡ Quick Summary
This indicator draws a line connecting significant price swings, ignoring small noise. It's great for:
Visualizing trend structure
Identifying chart patterns
Finding entry/exit levels
Spotting trend reversals Indicator

Cody Zig Zag Cody Zig Zag – MT4-Style Zig Zag for TradingView
The ZigZag indicator that actually works like the classic MT4 version!
🔍 Overview
Cody Zig Zag is a powerful, fully customizable ZigZag indicator that replicates the exact behavior of the popular MetaTrader 4 (MT4) ZigZag. Unlike TradingView's built-in ZigZag, this version behaves identically to what MT4 traders know and love – making it perfect for Elliott Wave traders, support/resistance hunters, and breakout specialists.
⚙️ Input Parameters (Just like MT4!)
Parameter Default Description
Depth 12 Minimum number of bars between swing points
Deviation 5 Minimum price movement (in ticks) to form a new swing
Backstep 2 Minimum bars between swing points of the same type
Line Thickness 2 Visual weight of the ZigZag line
Bull Color Lime Color for upward swings
Bear Color Red Color for downward swings
Repaint Levels True Enables real-time repainting (MT4 style)
🎯 Key Features
✅ TRUE MT4 BEHAVIOR – Exact replication of MetaTrader 4's classic ZigZag algorithm
✅ INTELLIGENT LABELS – Automatically identifies HH (Higher High), LH (Lower High), LL (Lower Low), and HL (Higher Low)
✅ REAL-TIME UPDATES – Optional repainting mode for live market analysis
✅ DIRECTION BACKGROUND – Visual market direction indicator (Green = Bullish, Red = Bearish)
✅ ALERT CONDITIONS – Get notified when the ZigZag direction changes
💡 How to Use
For Beginners:
Just add the indicator to your chart – the default settings (12,5,2) work perfectly for most timeframes!
For Advanced Traders:
Lower Depth (5-8) → More swings, more detail (scalping/1min charts)
Higher Depth (12-20) → Cleaner swings, fewer signals (swing trading/4H+ charts)
Adjust Deviation → Control minimum swing size based on volatility
🎨 Visual Guide
Lime Line = Price moving UP
Red Line = Price moving DOWN
HH Label = Higher High (uptrend continuation)
LH Label = Lower High (potential reversal down)
LL Label = Lower Low (downtrend continuation)
HL Label = Higher Low (potential reversal up)
📊 Best For
📌 Elliott Wave Counting – Perfect for identifying wave structure
📌 Support & Resistance – Automatically marks swing highs/lows
📌 Breakout Trading – Visualize clear break levels
📌 Divergence Trading – Spot hidden/regular divergences with RSI/MACD
📌 Harmonic Patterns – Identify XABCD patterns easily
⏰ Alert Conditions
Direction Changed – Triggered whenever the ZigZag changes direction
Bullish Direction – When price starts moving up
Bearish Direction – When price starts moving down
🔧 Troubleshooting
Q: Why does the indicator "repaint"?
A: That's how MT4 ZigZag works! Repainting shows the most accurate real-time swing points. Turn OFF "Repaint Levels" if you prefer traditional non-repainting behavior.
Q: What timeframes work best?
A: Works on ALL timeframes! Lower Depth values (5-8) for lower timeframes, higher Depth (12-20) for higher timeframes.
Q: Can I use this for automated strategies?
A: Yes! The alert conditions can trigger tradingview alerts for manual or webhook-based trading.
🙏 Credits
Original MT4 ZigZag logic ported to Pine Script™ v6 by lucemanb
Renamed and optimized as Cody Zig Zag
📝 Keywords
ZigZag MT4 Elliott Wave Swing High Swing Low Support Resistance Divergence Breakout Harmonic Patterns Price Action Trend Reversal Higher High Lower Low Technical Analysis TradingView Indicator Free Indicator
⭐ Support & Feedback
If you find this indicator useful:
Like & Follow for more tools
Leave a review with your suggestions
Share with your trading community
Happy Trading! 🚀
Disclaimer: This indicator is for educational and analytical purposes. Past performance does not guarantee future results. Always practice proper risk management. Indicator

ABCD Harmonic Projection [WillyAlgoTrader]📐 ABCD Harmonic Projection is an overlay indicator that automatically detects ABCD harmonic patterns from ZigZag pivots, validates them against Fibonacci ratio constraints (BC/AB retracement + CD/AB extension), scores each pattern with a 4-factor quality engine (0–100), projects the D-point completion zone, and draws Target and Stop zones with Fibonacci extension and retracement levels — with full TP/SL outcome tracking and separate bull/bear win rate statistics.
The ABCD pattern is one of the foundational harmonic structures: four alternating swing points (A→B→C→D) where the BC leg retraces a Fibonacci portion of the AB leg, and the CD leg extends from C toward a projected D-point that is a Fibonacci ratio of the AB leg. When price reaches the D-point, the pattern completes — and a reversal or continuation move is expected. This indicator automates the entire detection-to-target workflow: find the swings, measure the ratios, validate the geometry, project the target, and track the outcome.
🧩 WHY THESE COMPONENTS WORK TOGETHER
Manually identifying ABCD patterns requires eyeballing four pivot points, measuring two Fibonacci ratios, estimating the D-point projection, and drawing the target zone — across multiple instruments and timeframes. Most traders miss patterns or miscalculate ratios.
This indicator chains each step into an automated pipeline:
ZigZag pivot detection → 4-point ABCD extraction → BC/AB ratio validation → CD/AB extension calculation → D-point projection → 4-factor quality scoring → Target Zone + Stop Zone placement → Fibonacci extension/retracement overlay → TP/SL outcome tracking → Win rate statistics
The ZigZag engine ensures only confirmed alternating swings are used (no noise pivots). The ratio validation filters patterns to only those within Fibonacci-valid ranges. The quality scoring ranks patterns by how close they are to ideal geometry. The D-point projection gives a specific price target — not a vague area. And the Target/Stop zones provide precise trade management levels anchored to the pattern's own geometry.
🔍 WHAT MAKES IT ORIGINAL
1️⃣ ZigZag pivot engine with direction management.
The indicator uses a directional ZigZag that enforces strict alternation: after a swing high, only a swing low is accepted (and vice versa). If price makes a higher high during an existing up-leg, the previous swing high is updated in place (not duplicated). This prevents the common problem of multiple consecutive highs being treated as separate pivots.
Pivots are detected using ta.pivothigh/ta.pivotlow with configurable lookback (default 8 bars). The ZigZag stores prices, bar indices, and directions in parallel arrays — providing the last 200 pivots for pattern scanning.
2️⃣ Fibonacci-validated ABCD pattern detection.
When a new pivot is confirmed and at least 4 pivots exist, the indicator extracts the most recent A, B, C points and validates:
— BC/AB retracement ratio : must be between minBcAbRatio (default 0.382) and maxBcAbRatio (default 0.886). Classic ABCD ratios are 0.382, 0.500, 0.618, 0.786, and 0.886. Patterns outside this range are rejected.
— ATR minimum swing filter : the AB leg must be at least 1× ATR in size — filtering out noise patterns during low-volatility bars.
— Minimum leg depth : AB must span at least 3 bars — ensuring the pattern has temporal structure, not just a single spike.
Pattern direction: if B > A → bullish ABCD (D projected above C). If B < A → bearish ABCD (D projected below C).
The D-point is projected from C using the average of the configurable CD/AB ratio range: projectedD = C + direction × |AB| × avgCdAbRatio.
3️⃣ 4-factor pattern quality scoring (0–100).
Each detected pattern receives a quality score from four dimensions:
— 📐 Fibonacci precision (45 pts) : how close BC/AB is to the nearest standard Fibonacci level (0.382, 0.500, 0.618, 0.786, 0.886, 1.000, 1.272, 1.618). Exact Fib ratio = full points. 0.05 away = partial. 0.18+ away = zero. This is the most heavily weighted factor because Fibonacci alignment is the core of harmonic pattern validity.
— ⏱️ Time symmetry (25 pts) : the ratio of estimated CD bars to AB bars. Perfect symmetry (CD bars = AB bars) = 25 points. Asymmetric patterns (one leg much longer) score lower.
— ⚖️ Price symmetry (20 pts) : BC retracement depth relative to 0.618 — deeper retests (closer to 0.618) score higher. Very shallow pullbacks (e.g., 0.236) receive fewer points.
— 📏 Leg maturity (10 pts) : AB leg length in bars — patterns with 8+ bars get full points, 5+ get 7, 3+ get 3. Single-bar spikes score zero.
Patterns below the Min Pattern Score threshold (default 40) are not displayed.
4️⃣ Fibonacci extension levels projected from C.
Four AB extension levels are drawn from point C in the direction of the pattern:
— 0.786 × |AB| — shallow completion
— 1.000 × |AB| — classic equal-leg ABCD
— 1.272 × |AB| — extended completion
— 1.618 × |AB| — maximum extension
The 1.0 level is drawn thicker (2px, less transparency) as it represents the ideal equal-leg completion. Each level includes a price label. Additionally, the measured BC/AB retracement ratio is displayed at the midpoint of the BC leg for reference.
5️⃣ Fibonacci retracement levels within C→D (partial TP targets).
For active patterns, three retracement levels are drawn between C and the projected D:
— 0.382 of CD range — first partial profit target
— 0.500 of CD range — mid-target
— 0.618 of CD range — aggressive partial take
These provide natural exit levels before the full D-point is reached — useful for scaling out of positions progressively.
6️⃣ Target Zone + Stop Zone with geometric sizing.
On each pattern:
— TARGET ZONE : a band around the projected D-point, sized at 10% of the CD range. For bullish patterns: the zone sits just below D. For bearish: just above D. This is where the pattern completion trade expects to reach profit.
— STOP ZONE : a band around point C, also sized at 10% of CD range. For bullish patterns: below C. For bearish: above C. If price returns past C, the pattern structure is broken.
Both zones extend rightward until price touches the target zone (tracked by touch bar), or the pattern resolves (TP/SL hit). Zones use distinct colors: green for target, red for stop.
7️⃣ TP/SL outcome tracking with separate bull/bear statistics.
Each active pattern monitors:
— TP hit : price reaches the projected D-point (high ≥ D for bull, low ≤ D for bear)
— SL hit : price returns past C against the pattern direction (low ≤ C for bull, high ≥ C for bear)
— Simultaneous TP+SL on the same bar → resolved as loss (conservative)
On TP hit: R:R is calculated as |entry to TP| / |entry to SL| and accumulated. The dashboard shows separate bull and bear win rates with average R:R on wins.
8️⃣ Active-only display mode.
When "Show Active Only" is enabled (default), completed patterns (TP or SL already hit) are hidden — only the current live pattern remains on the chart. When disabled, up to maxPatterns historical patterns are shown for context. This prevents chart clutter while maintaining full statistical tracking.
9️⃣ One-active-pattern constraint.
The indicator only allows one active pattern at a time. When an active pattern exists (status = 0), no new patterns are detected. This prevents overlapping projections and conflicting zones. A new pattern can only be detected after the current one resolves (TP or SL).
⚙️ HOW IT WORKS — CALCULATION FLOW
Step 1 — ZigZag: Directional pivot detection with alternation enforcement. Higher highs update existing swing (no duplicate). Lower lows same. Pivots stored in parallel arrays.
Step 2 — Pattern extraction: On each new confirmed pivot: extract A (3rd-to-last), B (2nd-to-last), C (latest). Compute AB length, BC length, BC/AB ratio.
Step 3 — Validation: BC/AB within Fibonacci range? AB ≥ ATR? AB ≥ 3 bars? No active pattern already?
Step 4 — Scoring: 4 factors: Fibonacci precision (45), time symmetry (25), price symmetry (20), leg maturity (10). Score ≥ minScore → pattern accepted.
Step 5 — Projection: D = C + direction × |AB| × avgCdAbRatio. Bars capped at maxBarsProjection.
Step 6 — Drawing: On barstate.islast: delete-and-redraw all visible patterns. AB and BC legs as solid lines. CD projection as dotted. A/B/C/D labels. Score label. Target/Stop zones as boxes. Fib extension and retracement levels as dashed lines with price labels.
Step 7 — Evaluation: Each bar: check all active patterns for TP/SL hits. Update status, accumulate win/loss stats, record R:R.
📖 HOW TO USE
🎯 Quick start:
1. Add the indicator — ABCD patterns appear automatically as colored leg lines with A/B/C/D labels
2. Yellow dotted line from C = projected path to D
3. Green "TARGET ZONE" box = where price should reach (take profit)
4. Red "STOP ZONE" box = where the pattern is invalidated (stop loss)
5. Blue dashed lines = Fibonacci extension levels (0.786, 1.0, 1.272, 1.618)
6. Blue dotted lines = partial TP targets (0.382, 0.5, 0.618 of CD)
7. "Long"/"Short" label = confirmed entry signal
👁️ Reading the chart:
— 🟢 Green legs + labels = bullish ABCD (D above C, expecting up-move)
— 🔴 Red legs + labels = bearish ABCD (D below C, expecting down-move)
— 🟡 Dotted projection line = expected path C → D
— 🟢 "TARGET ZONE" box = profit target area around projected D
— 🔴 "STOP ZONE" box = invalidation area around C
— 🔵 Dashed lines = Fib extension levels from C (0.786/1.0/1.272/1.618 of AB)
— 🔵 Dotted lines = CD retracement levels (partial TPs: 0.382/0.5/0.618)
— Score label (e.g., "72%") = pattern quality
📊 Dashboard fields:
— Patterns: active / total count
— Last Signal: direction + status (Active/TP ✓/SL ✗) + score
— Bull W/L: wins/losses and win rate for bullish patterns
— Bear W/L: wins/losses and win rate for bearish patterns
— Avg R:R: average reward-to-risk on winning bull/bear trades
— ATR: current value for reference
— Timeframe, version
🔧 Tuning guide:
— Too many patterns: increase ZigZag Length (12–21), increase Min Score (60+), enable ATR filter
— Too few patterns: decrease ZigZag Length (5–8), decrease Min Score (30), widen BC/AB ratio range
— Patterns too small: increase ATR filter or ZigZag Length
— Want only perfect geometry: narrow BC/AB to 0.500–0.786, set CD/AB to 0.9–1.1, Min Score 70+
— Extended patterns: set Max CD/AB to 1.618 or higher
⚙️ KEY SETTINGS REFERENCE
⚙️ Main:
— ZigZag Length (default 8): pivot detection lookback
— Pivot Sources : configurable high/low sources
📐 Pattern:
— Min/Max BC/AB Ratio (default 0.382/0.886): Fibonacci retracement range
— Min/Max CD/AB Ratio (default 0.786/1.618): extension range for D projection
— Min Pattern Score (default 40): quality threshold
— ATR Filter (default On): minimum swing size
— Max Patterns (default 3): display limit
— Active Only (default On): hide completed patterns
🎨 Visual:
— Buy/Sell signals, D projection, Fib levels, TP/SL zones, A/B/C/D labels, score (all toggleable)
— Auto / Dark / Light theme
🔧 Advanced:
— Max Bars for D Projection (default 200): limits distant projections
🔔 Alerts
— 🟢 LONG ABCD / 🔴 SHORT ABCD — entry, TP, SL, score, pattern type
All support plain text and JSON webhook format. Bar-close confirmed.
⚠️ IMPORTANT NOTES
— 🚫 No repainting. All signals require barstate.isconfirmed and newPivot (confirmed ZigZag pivot). Patterns are detected after the pivot bar closes. Drawings are rendered on barstate.islast using delete-and-redraw — previous bar's pattern state is final.
— 📐 The ZigZag enforces strict alternation : high → low → high → low. If price makes a higher high during an existing up-swing, the previous high is updated in place — no duplicate pivots are created. This is essential for correct A/B/C/D extraction.
— ⚖️ Only one active pattern is allowed at a time. New patterns are blocked until the current one resolves (TP or SL). This prevents conflicting signals and overlapping zones.
— 📊 The quality score is heavily weighted toward Fibonacci precision (45 out of 100 points). A pattern with BC/AB exactly at 0.618 scores much higher than one at 0.450. This reflects the harmonic principle that Fibonacci alignment is the primary measure of pattern validity.
— 🔒 Simultaneous TP+SL on the same bar is resolved as a loss (conservative) . This prevents ambiguous outcomes from inflating win rates.
— 📏 The D-point projection uses the average of the min/max CD/AB ratio range — not the exact 1.0 (equal legs). With default settings (0.786–1.618), the projected D is at 1.202× AB from C — between classic and extended. Adjust the CD/AB range to target specific completion types.
— 🛠️ This is a harmonic pattern detection and projection tool , not an automated trading bot. It identifies ABCD geometry, projects D-point targets, and provides structured trade zones — trade decisions remain yours.
— 🌐 Works on all markets and timeframes. Indicator

Zigzag Sequence DetectorOVERVIEW
This indicator is a dynamic pattern recognition tool built strictly on market structure mechanics. It detects custom sequences of Zigzag-based pivot points in real-time. It was developed to automate the tedious process of visually tracking structural shifts and to provide a programmatic foundation for sequence-based trading. It falls into the category of Price Action and Market Structure analysis.
MAIN CONCEPT
If we consider the market as a massive text, this script can be seen as a 'scanning tool' that finds the exact sentence we are looking for it. You write a sentence consisting of the words 'HH, HL, LL, and LH', and this indicator highlights exactly where that sequence occurs in the text.
ZIGZAG & PIVOTS
The core of this tool relies on the ZigZag algorithm, which filters out market noise by only drawing lines when the price reverses by a defined threshold. It reveals the skeletal framework of price action. At the peaks and troughs of these lines lie the pivot points: Higher High (HH), Lower Low (LL), Higher Low (HL), and Lower High (LH). In trading literature, these pivots are the fundamental building blocks of Dow Theory. Tracking these points provides a raw, unfiltered narrative of whether buyers or sellers are in control.
There are many ZigZag alternatives on TradingView that can produce effective results. However, the open-source model developed by @DevLucem provides, in my opinion, the most suitable structure to work on. The original version was based on percentage deviation; I made a minor addition for Mintick-based calculation and update it to version 6 of Pine Script. Special thanks to for his inspiring work.
MECHANICS
• The internal logic uses `chart.point` objects to cleanly track price and time coordinates. As the direction shifts, these objects are copied to maintain independent references.
• `f_calc_dev()`: Dynamically calculates the deviation threshold based on the user's selection (Mintick or Percent).
• `f_parse_sequence()`: Takes the raw string input, strips whitespaces, and splits it into a clean array for processing.
• `f_check_sequence()`: Isolates the most recent elements of the historical pivot array and evaluates them against the user's target sequence array element by element.
• The `trade_direction` state machine uses a unique integer-based accumulation system rather than a simple binary (1 or -1) toggle. It increments (+1, +2) for consecutive Long signals and decrements (-1, -2) for consecutive Shorts. This makes the script highly adaptable for developers building pyramiding strategies or dynamic position sizing models.
HOW TO USE
• Load the indicator on your chart and set your noise-filtering parameters via `Depth`, `Deviation Mode`, `Deviation Value`, and `Backstep`.
• In the settings, input your desired market structures for Entries and Exits using comma-separated values (e.g., "HH,HL,LH").
• You can define Long Entry, Long Exit, Short Entry and Short Exit conditions independently.
• You can also toggle the visual outputs on or off and set the colors in the indicator settings.
THE ALTERNATING PIVOT RULE (Important Note on Sequence Building)
• By the inherent geometric laws of the ZigZag algorithm, market structure must strictly alternate between a peak (High) and a trough (Low). It is structurally impossible for two consecutive peaks or two consecutive troughs to form. Therefore, when building your custom patterns, a High-type pivot must always be followed by a Low-type pivot, and vice versa.
• Invalid Sequences: "HH, HH", "HH, LH", "LH, HH", "LH, LH", "LL, LL", "LL, HL", "HL, LL", "HL, HL". (The engine will accept these inputs, but the condition will never occur on the chart, meaning no signals will ever trigger.)
• Always ensure your custom text sequences obey this strict alternating logic before expecting valid signals.
OUTPUTS
• The script plots ZigZag lines and annotates each confirmed pivot directly on the chart.
• Upon detecting a target sequence, it displays Entry or Exit signals on the triggering bar.
• It continuously feeds raw data (such as the exact `trade_direction` integer and active signal states) into the Data Window for quantitative tracking.
• It allows for setting automated Tradingview alerts based entry and exit signals.
DISCLAIMER
• The default signal sequences are provided for demonstration purposes only; it is the user's responsibility to define meaningful patterns.
• This indicator is not a standalone trading strategy or a predictive tool.
• It mathematically identifies what has already happened based on rigid pivot definitions.
• If the `Last Leg (Repaint)` option is enabled, it evaluates the developing market structure in real-time. This means signals on the current bar can appear and vanish if the price reverses before the pivot is locked in. Indicator

ZigZag Fibo Cluster (PRZ)This indicator is designed to identify high-probability Potential Reversal Zones (PRZ) by combining Multi-Timeframe (MTF) analysis with Fibonacci clusters. It focuses on filtering out market noise to find mathematically validated support and resistance levels, making it highly effective for intraday trading and sniper entries.
Core Logic & Key Features:
Dual-Layer ZigZag Architecture: The system simultaneously tracks two different ZigZag structures on the chart. It calculates a "Major" wave (default 10-5) for higher timeframes (1D, 4H, 1H) and a "Minor" wave (default 6-3) for the active lower timeframe (e.g., 20m).
Fibonacci Cluster (Kissing) Detector: Fibonacci retracements and extensions from different timeframes rarely align perfectly. This indicator continuously cross-references the active Fibo levels from the Major and Minor structures to find algorithmic overlaps.
Strict 0.1% Precision Tolerance: When a Major Fibonacci level and a Minor Fibonacci level converge within a strict 0.1% price margin, the system validates this as a "Cluster" and plots a precise "PRZ ±0.1%" label on the chart.
Visual Clarity & Chart Cleanliness: It prevents chart clutter by hiding hundreds of irrelevant Fibonacci lines. It only prints labels where the 0.1% tolerance condition is met—meaning both the macro and micro structures agree on the reversal point. Historical wave references are kept as subtle dotted lines.
Dynamic Customization: All ZigZag deviation parameters (Left/Right bars) and extended Fibonacci levels (1.272, 1.618, -0.618, etc.) can be fully customized via the settings menu to adapt to different asset volatilities.
How to Use:
When the "PRZ ±0.1%" label appears, it indicates that the current price action has reached both its macro and micro algorithmic targets. These specific zones provide asymmetric risk/reward opportunities, allowing traders to plan trend reversals, define take-profit areas, or execute counter-trend trades with extremely tight stop-loss margins. Indicator

Zig Zag ++ SG (Premium)🔥 Zig Zag ++ SG
Professional Market Structure & Cycle Analyzer
Zig Zag ++ SG is an advanced, research-grade market structure indicator built on top of a refined ZigZag engine, designed for traders and investors who want to understand price cycles, not chase candles.
This is not a buy-sell arrow tool.
It is a decision-support system used to analyze trend strength, exhaustion, pullback depth, and cycle behavior across any market and timeframe.
🧠 What Makes Zig Zag ++ SG Different?
Most ZigZag indicators only draw lines.
Zig Zag ++ SG answers the real questions:
Is the trend getting stronger or weaker?
Are higher highs still meaningful?
How deep are pullbacks in percentage terms?
Which stocks recover fast vs stay weak?
Is this accumulation, distribution, or reversal?
It does this by combining:
Market Structure (HH / HL / LH / LL)
Consecutive structure counting
Gain & fall percentage per swing
Clean visual logic (no repaint confusion)
📌 Core Features
✅ 1. Automatic Market Structure Detection
Labels every major swing as:
HH – Higher High
HL – Higher Low
LH – Lower High
LL – Lower Low
This instantly shows whether the market is:
Trending
Consolidating
Distributing
Reversing
✅ 2. Consecutive Structure Count (ON by default)
Each structure type is counted sequentially:
HH (1), HH (2), HH (3)…
HL (1), HL (2)…
This reveals:
Trend maturity
Exhaustion zones
Early breakdown warnings
Example:
HH (4) = trend may be overextended
HL (3) = healthy trend continuation
✅ 3. Gain & Fall % on Every Swing (ON by default)
Every HH, HL, LH, LL shows:
Exact % move from the previous pivot
This allows you to:
Compare pullback depth across stocks
Identify leaders (shallow HLs)
Spot weak stocks (deep HLs / LHs)
Study cycle symmetry
Example label:
HL (2)
-6.4%
✅ 4. Clean, Readable Visual Design
🟩 Green labels → White text
🟥 Red labels → High-contrast white text
Optional background trend shading (OFF by default)
Works perfectly in dark & light mode
Designed for long chart study sessions, not flashy screenshots.
✅ 5. Safe Repaint Logic (Transparent by Design)
Uses ZigZag logic intentionally
No fake “non-repainting” claims
Ideal for analysis, research & planning
What you see is structurally correct
This indicator is for thinking traders, not signal chasers.
⚙️ Best Settings (Recommended)
🔹 Intraday Trading
Timeframe: 5m / 15m
Depth: 8–10
Deviation: 3–5
Backstep: 2
🔹 Swing Trading (Most Popular)
Timeframe: Daily
Depth: 12–15
Deviation: 5
Backstep: 2
🔹 Long-Term / Investing
Timeframe: Weekly
Depth: 15–20
Deviation: 5–8
Backstep: 3
💡 Tip:
Lower depth = more swings
Higher depth = cleaner, major cycles
📈 How to Use Zig Zag ++ SG (Practically)
🔹 Trend Strength
HH (3+) + HL (2–3)
→ Strong, healthy trend
🔹 Exhaustion Warning
HH (4+)
→ Risk of distribution or slowdown
🔹 Pullback Quality
HL −3% to −7%
→ Strong stock
HL −12% to −20%
→ Weak hands / fragile trend
🔹 Reversal Confirmation
LH followed by LL (2+)
→ Trend change likely
🧪 Who Is This Indicator For?
✅ Swing traders
✅ Positional traders
✅ Long-term investors
✅ Market structure students
✅ Stock researchers
✅ Anyone tired of noisy indicators
❌ Not for:
People wanting instant buy/sell arrows
Scalpers chasing 1-minute signals
“Magic indicator” seekers
💎 Why This Is Worth Purchasing
Built with Pine Script v6 best practices
Solves real market questions
Helps avoid:
Buying late
Selling early
Holding weak stocks too long
Encourages process-driven trading
One-time learning tool you’ll use for years
Most traders lose money not because of entries —
but because they misread structure and cycles.
Zig Zag ++ SG fixes that. Indicator

Zigzag Simple [SCL]🟩 OVERVIEW
Draws zigzag lines from pivot Highs to pivot Lows. You can choose between three different ways of calculating pivots:
• True Highs and Lows
• Williams pivots
• Oscillator pivots
🟩 HOW TO USE
This indicator can be used to understand market structure, which is arguably the primary thing you need to be aware of when trading. The zigzag by itself does not display a market structure bias, nor any information about prices of pivots, HH and HL labels, or anything like that. Nevertheless, a simple zigzag is perhaps the easiest and most intuitive way to understand what price is doing.
Choose a pivot style that you like, customise the colours and line style, and enjoy!
🟩 PIVOT TYPES EXPLAINED
True Highs and Lows
This is not an invention of mine (all credit to my humble mentor), but I haven't seen anyone else code them up. A true High is a close below the low of the candle with the highest high. A true Low is a close above the high of a candle with the lowest low. These are solid, price action-based pivots that can sometimes confirm quickly.
Williams pivots
This is how most people calculate pivots. They're simply the highest high for x bars back and x bars forwards. They're the vanilla of pivots IMO: serviceable but not very interesting. They're very convenient to code because there are built-in Pine functions for them: ta.pivothigh and ta.pivotlow . They confirm a predictable number of bars after they happen, which is great for coding but also makes the trader wait for confirmation.
Oscillator pivots
This is a completely different concept, which uses momentum in order to define pivots. For example, when you get a rise in momentum and momentum then drops a configurable amount, it confirms a pivot high, and vice versa for a pivot low. I don't know if anyone else does it –- although some indicators do mark pivots in momentum itself, and plenty do divergences, I wasn't able to find one that specifically marked *pivots in price* because of pivots in momentum 🤷♂️
Anyway, while this approach needs a whole investigation on its own, here we simply plot some pivots in a smoothed RSI. This indicator doesn't plot the actual momentum values -- for a more visual understanding of how this works, refer to the examples in the OscillatorPivots library.
🟩 UNIQUE ADVANTAGES
In contrast to other zigzag indicators available, this one lets you choose between the standard and some more unique methods of generating the zigzags. Additionally, because it's based on libraries, it is relatively easy for programmers to use as a basis for experimentation.
🟩 GEEK STUFF
Although there is considerable practical use for pivot-based zigzags in trading, this script is primarily a demonstration in coding -- specifically the power of libraries!
Most of the script consists of setup, especially defining inputs. The final section sacrifices some readability for conciseness, simply to emphasise how little code you need when the heavy lifting is done by libraries .
The actual calculations and drawing are achieved in just 8 lines.
The equivalent code in the libraries is ~250 lines long.
All libraries used are my own, public and open-source:
• MarketStructure
• DrawZigZag
• OscillatorPivots Indicator

DrawZigZag🟩 OVERVIEW
This library draws zigzag lines for existing pivots. It is designed to be simple to use. If your script creates pivots and you want to join them up while handling edge cases, this library does that quickly and efficiently. If you want your pivots created for you, choose one of the many other zigzag libraries that do that.
🟩 HOW TO USE
Pine Script libraries contain reusable code for importing into indicators. You do not need to copy any code out of here. Just import the library and call the function you want.
For example, for version 1 of this library, import it like this:
import SimpleCryptoLife/DrawZigZag/1
See the EXAMPLE USAGE sections within the library for examples of calling the functions.
For more information on libraries and incorporating them into your scripts, see the Libraries section of the Pine Script User Manual.
🟩 WHAT IT DOES
I looked at every zigzag library on TradingView, after finishing this one. They all seemed to fall into two groups in terms of functionality:
• Create the pivots themselves, using a combination of Williams-style pivots and sometimes price distance.
• Require an array of pivot information, often in a format that uses user-defined types.
My library takes a completely different approach.
Firstly, it only does the drawing. It doesn't calculate the pivots for you. This isn't laziness. There are so many ways to define pivots and that should be up to you. If you've followed my work on market structure you know what I think of Williams pivots.
Secondly, when you pass information about your pivots to the library function, you only need the minimum of pivot information -- whether it's a High or Low pivot, the price, and the bar index. Pass these as normal variables -- bools, ints, and floats -- on the fly as your pivots confirm. It is completely agnostic as to how you derive your pivots. If they are confirmed an arbitrary number of bars after they happen, that's fine.
So why even bother using it if all it does it draw some lines?
Turns out there is quite some logic needed in order to connect highs and lows in the right way, and to handle edge cases. This is the kind of thing one can happily outsource.
🟩 THE RULES
• Zigs and zags must alternate between Highs and Lows. We never connect a High to a High or a Low to a Low.
• If a candle has both a High and Low pivot confirmed on it, the first line is drawn to the end of the candle that is the opposite to the previous pivot. Then the next line goes vertically through the candle to the other end, and then after that continues normally.
• If we draw a line up from a Low to a High pivot, and another High pivot comes in higher, we *extend* the line up, and the same for lines down. Yes this is a form of repainting. It is in my opinion the only way to end up with a correct structure.
• We ignore lower highs on the way up and higher lows on the way down.
🟩 WHAT'S COOL ABOUT THIS LIBRARY
• It's simple and lightweight: no exported user-defined types, no helper methods, no matrices.
• It's really fast. In my profiling it runs at about ~50ms, and changing the options (e.g., trimming the array) doesn't make very much difference.
• You only need to call one function, which does all the calculations and draws all lines.
• There are two variations of this function though -- one simple function that just draws lines, and one slightly more advanced method that modifies an array containing the lines. If you don't know which one you want, use the simpler one.
🟩 GEEK STUFF
• There are no dependencies on other libraries.
• I tried to make the logic as clear as I could and comment it appropriately.
• In the `f_drawZigZags` function, the line variable is declared using the `var` keyword *inside* the function, for simplicity. For this reason, it persists between function calls *only* if the function is called from the global scope or a local if block. In general, if a function is called from inside a loop , or multiple times from different contexts, persistent variables inside that function are re-initialised on each call. In this case, this re-initialisation would mean that the function loses track of the previous line, resulting in incorrect drawings. This is why you cannot call the `f_drawZigZags` function from a loop (not that there's any reason to). The `m_drawZigZagsArray` does not use any internal `var` variables.
• The function itself takes a Boolean parameter `_showZigZag`, which turns the drawings on and off, so there is no need to call the function conditionally. In the examples, we do call the functions from an if block, purely as an illustration of how to increase performance by restricting the amount of code that needs to be run.
🟩 BRING ON THE FUNCTIONS
f_drawZigZags(_showZigZag, _isHighPivot, _isLowPivot, _highPivotPrice, _lowPivotPrice, _pivotIndex, _zigzagWidth, _lineStyle, _upZigColour, _downZagColour)
This function creates or extends the latest zigzag line. Takes real-time information about pivots and draws lines. It does not calculate the pivots. It must be called once per script and cannot be called from a loop.
Parameters:
_showZigZag (bool) : Whether to show the zigzag lines.
_isHighPivot (bool) : Whether the current bar confirms a high pivot. Note that pivots are confirmed after the bar in which they occur.
_isLowPivot (bool) : Whether the current bar confirms a low pivot.
_highPivotPrice (float) : The price of the high pivot that was confirmed this bar. It is NOT the high price of the current bar.
_lowPivotPrice (float) : The price of the low pivot that was confirmed this bar. It is NOT the low price of the current bar.
_pivotIndex (int) : The bar index of the pivot that was confirmed this bar. This is not an offset. It's the `bar_index` value of the pivot.
_zigzagWidth (int) : The width of the zigzag lines.
_lineStyle (string) : The style of the zigzag lines.
_upZigColour (color) : The colour of the up zigzag lines.
_downZagColour (color) : The colour of the down zigzag lines.
Returns: The function has no explicit returns. As a side effect, it draws or updates zigzag lines.
method m_drawZigZagsArray(_a_zigZagLines, _showZigZag, _isHighPivot, _isLowPivot, _highPivotPrice, _lowPivotPrice, _pivotIndex, _zigzagWidth, _lineStyle, _upZigColour, _downZagColour, _trimArray)
Namespace types: array
Parameters:
_a_zigZagLines (array)
_showZigZag (bool) : Whether to show the zigzag lines.
_isHighPivot (bool) : Whether the current bar confirms a high pivot. Note that pivots are usually confirmed after the bar in which they occur.
_isLowPivot (bool) : Whether the current bar confirms a low pivot.
_highPivotPrice (float) : The price of the high pivot that was confirmed this bar. It is NOT the high price of the current bar.
_lowPivotPrice (float) : The price of the low pivot that was confirmed this bar. It is NOT the low price of the current bar.
_pivotIndex (int) : The bar index of the pivot that was confirmed this bar. This is not an offset. It's the `bar_index` value of the pivot.
_zigzagWidth (int) : The width of the zigzag lines.
_lineStyle (string) : The style of the zigzag lines.
_upZigColour (color) : The colour of the up zigzag lines.
_downZagColour (color) : The colour of the down zigzag lines.
_trimArray (bool) : If true, the array of lines is kept to a maximum size of two lines (the line elements are not deleted). If false (the default), the array is kept to a maximum of 500 lines (the maximum number of line objects a single Pine script can display).
Returns: This function has no explicit returns but it modifies a global array of zigzag lines. Library

Fibonacci - DolphinTradeBot
OVERVIEW
The 'Fibonacci - DolphinTradeBot' indicator is a Pine Script-based tool for TradingView that dynamically identifies key Fibonacci retracement levels using ZigZag price movements. It aims to replicate the Fibonacci Retracement tool available in TradingView’s drawing tools. The indicator calculates Fibonacci levels based on directional price changes, marking critical retracement zones such as 0, 0.236, 0.382, 0.5, 0.618, 0.786, and 1.0 on the chart. These levels are visualized with lines and labels, providing traders with precise areas of potential price reversals or trend continuation.
HOW IT WORKS ?
The indicator follows a zigzag formation. After a large swing movement, when new swings are formed without breaking the upper and lower levels, it places Fibonacci levels at the beginning and end points of the major swing movement."
▪️(Bullish) Structure :High → HigherLow → LowerHigh
▪️(Bearish) Structure :Low → LowerHigh → HigherLow
▪️When Fibonacci retracement levels are determined, a "📌" mark appears on the chart.
▪️If the price closes outside of these levels, a "❌" mark will appear.
USAGE
This indicator is designed to plot Fibonacci levels within an accumulation zone following significant price movements, helping you identify potential support and resistance. You can adjust the pivot periods to customize the zigzag settings to your preference. While classic Fibonacci levels are used by default, you also have the option to input custom levels and assign your preferred colors.
Set the Fibonacci direction option to "upward" to detect only bullish structures, "downward" to detect only bearish structures, and "both" to see both at the same time.
"To view past levels, simply enable the ' Show Previous Levels ' option, and to display the zigzag lines, activate the ' Show Zigzag ' setting."
ALERTS
The indicator, by default, triggers an alarm when both a level is formed and when a level is broken. However, if you'd like, you can select the desired level from the " Select Level " section in the indicator settings and set the alarm based on one of the conditions below.
▪️ cross-up → If the price breaks the Fibonacci level to the upside.
▪️ cross-down → If the price breaks the Fibonacci level to the downside.
▪️ cross-any → If the price breaks the Fibonacci level in any direction.
Indicator

Harmonic Patterns Library [TradingFinder]🔵 Introduction
Harmonic patterns blend geometric shapes with Fibonacci numbers, making these numbers fundamental to understanding the patterns.
One person who has done a lot of research on harmonic patterns is Scott Carney.Scott Carney's research on harmonic patterns in technical analysis focuses on precise price structures based on Fibonacci ratios to identify market reversals.
Key patterns include the Gartley, Bat, Butterfly, and Crab, each with specific alignment criteria. These patterns help traders anticipate potential market turning points and make informed trading decisions, enhancing the predictability of technical analysis.
🟣 Understanding 5-Point Harmonic Patterns
In the current library version, you can easily draw and customize most XABCD patterns. These patterns often form M or W shapes, or a combination of both. By calculating the Fibonacci ratios between key points, you can estimate potential price movements.
All five-point patterns share a similar structure, differing only in line lengths and Fibonacci ratios. Learning one pattern simplifies understanding others.
🟣 Exploring the Gartley Pattern
The Gartley pattern appears in both bullish (M shape) and bearish (W shape) forms. In the bullish Gartley, point X is below point D, and point A surpasses point C. Point D marks the start of a strong upward trend, making it an optimal point to place a buy order.
The bearish Gartley mirrors the bullish pattern with inverted Fibonacci ratios. In this scenario, point D indicates the start of a significant price drop. Traders can place sell orders at this point and buy at lower prices for profit in two-way markets.
🟣 Analyzing the Butterfly Pattern
The Butterfly pattern also manifests in bullish (M shape) and bearish (W shape) forms. It resembles the Gartley pattern but with point D lower than point X in the bullish version.
The Butterfly pattern involves deeper price corrections than the Gartley, leading to more significant price fluctuations. Point D in the bullish Butterfly indicates the beginning of a sharp price rise, making it an entry point for buy orders.
The bearish Butterfly has inverted Fibonacci ratios, with point D marking the start of a sharp price decline, ideal for sell orders followed by buying at lower prices in two-way markets.
🟣 Insights into the Bat Pattern
The Bat pattern, appearing in bullish (M shape) and bearish (W shape) forms, is one of the most precise harmonic patterns. It closely resembles the Butterfly and Gartley patterns, differing mainly in Fibonacci levels.
The bearish Bat pattern shares the Fibonacci ratios with the bullish Bat, with an inverted structure. Point D in the bearish Bat marks the start of a significant price drop, suitable for sell orders followed by buying at lower prices for profit.
🟣 The Crab Pattern Explained
The Crab pattern, found in both bullish (M shape) and bearish (W shape) forms, is highly favored by analysts. Discovered in 2000, the Crab pattern features a larger final wave correction compared to other harmonic patterns.
The bearish Crab shares Fibonacci ratios with the bullish version but in an inverted form. Point D in the bearish Crab signifies the start of a sharp price decline, making it an ideal point for sell orders followed by buying at lower prices for profitable trades.
🟣 Understanding the Shark Pattern
The Shark pattern appears in bullish (M shape) and bearish (W shape) forms. It differs from previous patterns as point C in the bullish Shark surpasses point A, with unique level measurements.
The bearish Shark pattern mirrors the Fibonacci ratios of the bullish Shark but is inverted. Point D in the bearish Shark indicates the start of a sharp price drop, ideal for placing sell orders and buying at lower prices to capitalize on the pattern.
🟣 The Cypher Pattern Overview
The Cypher pattern is another that appears in both bullish (M shape) and bearish (W shape) forms. It resembles the Shark pattern, with point C in the bullish Cypher extending beyond point A, and point D forming within the XA line.
The bearish Cypher shares the Fibonacci ratios with the bullish Cypher but in an inverted structure. Point D in the bearish Cypher marks the start of a significant price drop, perfect for sell orders followed by buying at lower prices.
🟣 Introducing the Nen-Star Pattern
The Nen-Star pattern appears in both bullish (M shape) and bearish (W shape) forms. In the bullish Nen-Star, point C extends beyond point A, and point D, the final point, forms outside the XA line, making CD the longest wave.
The bearish Nen-Star has inverted Fibonacci ratios, with point D indicating the start of a significant price drop. Traders can place sell orders at point D and buy at lower prices to profit from this pattern in two-way markets.
The 5-point harmonic patterns, commonly referred to as XABCD patterns, are specific geometric price structures identified in financial markets. These patterns are used by traders to predict potential price movements based on historical price data and Fibonacci retracement levels.
Here are the main 5-point harmonic patterns :
Gartley Pattern
Anti-Gartley Pattern
Bat Pattern
Anti-Bat Pattern
Alternate Bat Pattern
Butterfly Pattern
Anti-Butterfly Pattern
Crab Pattern
Anti-Crab Pattern
Deep Crab Pattern
Shark Pattern
Anti- Shark Pattern
Anti Alternate Shark Pattern
Cypher Pattern
Anti-Cypher Pattern
🔵 How to Use
To add "Order Block Refiner Library", you must first add the following code to your script.
import TFlab/Harmonic_Chart_Pattern_Library_TradingFinder/1 as HP
🟣 Parameters
XABCD(Name, Type, Show, Color, LineWidth, LabelSize, ShVF, FLPC, FLPCPeriod, Pivot, ABXAmin, ABXAmax, BCABmin, BCABmax, CDBCmin, CDBCmax, CDXAmin, CDXAmax) =>
Parameters:
Name (string)
Type (string)
Show (bool)
Color (color)
LineWidth (int)
LabelSize (string)
ShVF (bool)
FLPC (bool)
FLPCPeriod (int)
Pivot (int)
ABXAmin (float)
ABXAmax (float)
BCABmin (float)
BCABmax (float)
CDBCmin (float)
CDBCmax (float)
CDXAmin (float)
CDXAmax (float)
🟣 Genaral Parameters
Name : The name of the pattern.
Type: Enter "Bullish" to draw a Bullish pattern and "Bearish" to draw an Bearish pattern.
Show : Enter "true" to display the template and "false" to not display the template.
Color : Enter the desired color to draw the pattern in this parameter.
LineWidth : You can enter the number 1 or numbers higher than one to adjust the thickness of the drawing lines. This number must be an integer and increases with increasing thickness.
LabelSize : You can adjust the size of the labels by using the "size.auto", "size.tiny", "size.smal", "size.normal", "size.large" or "size.huge" entries.
🟣 Logical Parameters
ShVF : If this parameter is on "true" mode, only patterns will be displayed that they have exact format and no noise can be seen in them. If "false" is, the patterns displayed that maybe are noisy and do not exactly correspond to the original pattern.
FLPC : if Turned on, you can see this ability of patterns when their last pivot is formed. If this feature is off, it will see the patterns as soon as they are formed. The advantage of this option being clear is less formation of fielded patterns, and it is accompanied by the lateest pattern seeing and a sharp reduction in reward to risk.
FLPCPeriod : Using this parameter you can determine that the last pivot is based on Pivot period.
Pivot : You need to determine the period of the zigzag indicator. This factor is the most important parameter in pattern recognition.
ABXAmin : Minimum retracement of "AB" line compared to "XA" line.
ABXAmax : Maximum retracement of "AB" line compared to "XA" line.
BCABmin : Minimum retracement of "BC" line compared to "AB" line.
BCABmax : Maximum retracement of "BC" line compared to "AB" line.
CDBCmin : Minimum retracement of "CD" line compared to "BC" line.
CDBCmax : Maximum retracement of "CD" line compared to "BC" line.
CDXAmin : Minimum retracement of "CD" line compared to "XA" line.
CDXAmax : Maximum retracement of "CD" line compared to "XA" line.
🟣 Function Outputs
This library has two outputs. The first output is related to the alert of the formation of a new pattern. And the second output is related to the formation of the candlestick pattern and you can draw it using the "plotshape" tool.
Candle Confirmation Logic :
Example :
import TFlab/Harmonic_Chart_Pattern_Library_TradingFinder/1 as HP
PP = input.int(3, 'ZigZag Pivot Period')
ShowBull = input.bool(true, 'Show Bullish Pattern')
ShowBear = input.bool(true, 'Show Bearish Pattern')
ColorBull = input.color(#0609bb, 'Color Bullish Pattern')
ColorBear = input.color(#0609bb, 'Color Bearish Pattern')
LineWidth = input.int(1 , 'Width Line')
LabelSize = input.string(size.small , 'Label size' , options = )
ShVF = input.bool(false , 'Show Valid Format')
FLPC = input.bool(false , 'Show Formation Last Pivot Confirm')
FLPCPeriod =input.int(2, 'Period of Formation Last Pivot')
//Call function
= HP.XABCD('Bullish Bat', 'Bullish', ShowBull, ColorBull , LineWidth, LabelSize ,ShVF, FLPC, FLPCPeriod, PP, 0.382, 0.50, 0.382, 0.886, 1.618, 2.618, 0.85, 0.9)
= HP.XABCD('Bearish Bat', 'Bearish', ShowBear, ColorBear , LineWidth, LabelSize ,ShVF, FLPC, FLPCPeriod, PP, 0.382, 0.50, 0.382, 0.886, 1.618, 2.618, 0.85, 0.9)
//Alert
if BearAlert
alert('Bearish Harmonic')
if BullAlert
alert('Bulish Harmonic')
//CandleStick Confirm
plotshape(BearCandleConfirm, style = shape.arrowdown, color = color.red)
plotshape(BullCandleConfirm, style = shape.arrowup, color = color.green, location = location.belowbar )
Library

ZigZag Smart Trend [TradingFinder] Major & Minor Structured Wave🔵 Introduction
🟣 Zigzag
Zigzag is a lagging indicator; this indicator identifies points on a price chart that have more significant changes than its previous wave and then by connecting these lines to each other, it assists traders in trend detection.
This indicator reduces random price fluctuations and attempts to make the primary price trend clearer.
🟣 Pivot
Pivots are points where the price chart changes direction. Pivots, also called reversal points, form when supply and demand forces dominate one another.
Different types of technical analysis pivots can be introduced into two categories, minor pivots, and major pivots, each of which has a specific meaning in analysis.
Major Pivot : These pivots actually indicate major changes in the direction of the chart and occur at the end of trends. Analysts seeking to reach the primary analysis focus more on major pivot points. In fact, most technical analysis tools are examined and determined based on major pivots.
Minor Pivot : This type of pivot focuses more on small and subsidiary points and directions. Therefore, it occurs at the end of corrections. Analysts focusing on minor pivots represent small trends, and it should be noted that minor pivots are not suitable for use in primary technical tools.
How to identify minor and major pivots :
Minor pivots are pivots formed between two major pivots and fail to break the opposite major pivot.
Major pivots are pivots that have either successfully broken the opposite pivot or have moved more than the previous pivot of the same type.
🔵 How to use
Based on identifying pivots and drawing zigzag lines, you can have various uses for this indicator.
Identifying support and resistance levels :
Identifying Elliott Waves :
Identifying classic patterns :
Identifying pivots with higher validity :
Identifying internal and external breakouts :
Identifying trends and range areas :
Identifying pivot types along with major and minor recognition :
MHH : Major Higher High
MLH : Major Lower High
MLL : Major Lower Low
MHL : Major Higher Low
mHH : Minor Higher High
mLH : Minor Lower High
mLL : Minor Lower Low
mHL : Minor Higher Low
🔵 Settings
Pivot Period Zigzag Line : Using this input, you can determine the pivot period for identifying zigzag swings.
Show Zigzag Line : To show or not to show the zigzag line.
Zigzag Line Color : Change the color of the zigzag line.
Zigzag Line Style : Change the Style of the zigzag line.
Zigzag Line Width : Change the Width of the zigzag line.
Show Label : To show or not to show Pivot Type.
Color Label : Change the color of the Pivot Type Label.
Indicator

ZigZag Library [TradingFinder]🔵 Introduction
The "Zig Zag" indicator is an analytical tool that emerges from pricing changes. Essentially, it connects consecutive high and low points in an oscillatory manner. This method helps decipher price changes and can also be useful in identifying traditional patterns.
By sifting through partial price changes, "Zig Zag" can effectively pinpoint price fluctuations within defined time intervals.
🔵 Key Features
1. Drawing the Zig Zag based on Pivot points :
The algorithm is based on pivots that operate consecutively and alternately (switch between high and low swing). In this way, zigzag lines are connected from a swing high to a swing low and from a swing low to a swing high.
Also, with a very low probability, it is possible to have both low pivots and high pivots in one candle. In these cases, the algorithm tries to make the best decision to make the most suitable choice.
You can control what period these decisions are based on through the "PiPe" parameter.
2.Naming and labeling each pivot based on its position as "Higher High" (HH), "Lower Low" (LL), "Higher Low" (HL), and "Lower High" (LH).
Additionally, classic patterns such as HH, LH, LL, and HL can be recognized. All traders analyzing financial markets using classic patterns and Elliot Waves can benefit from the "zigzag" indicator to facilitate their analysis.
" HH ": When the price is higher than the previous peak (Higher High).
" HL ": When the price is higher than the previous low (Higher Low).
" LH ": When the price is lower than the previous peak (Lower High).
" LL ": When the price is lower than the previous low (Lower Low).
🔵 How to Use
First, you can add the library to your code as shown in the example below.
import TFlab/ZigZagLibrary_TradingFinder/1 as ZZ
Function "ZigZag" Parameters :
🟣 Logical Parameters
1. HIGH : You should place the "high" value here. High is a float variable.
2. LOW : You should place the "low" value here. Low is a float variable.
3. BAR_INDEX : You should place the "bar_index" value here. Bar_index is an integer variable.
4. PiPe : The desired pivot period for plotting Zig Zag is placed in this parameter. For example, if you intend to draw a Zig Zag with a Swing Period of 5, you should input 5.
PiPe is an integer variable.
Important :
Apart from the "PiPe" indicator, which is part of the customization capabilities of this indicator, you can create a multi-time frame mode for the indicator using 3 parameters "High", "Low" and "BAR_INDEX". In this way, instead of the data of the current time frame, use the data of other time frames.
Note that it is better to use the current time frame data, because using the multi-time frame mode is associated with challenges that may cause bugs in your code.
🟣 Setting Parameters
5. SHOW_LINE : It's a boolean variable. When true, the Zig Zag line is displayed, and when false, the Zig Zag line display is disabled.
6. STYLE_LINE : In this variable, you can determine the style of the Zig Zag line. You can input one of the 3 options: line.style_solid, line.style_dotted, line.style_dashed. STYLE_LINE is a constant string variable.
7. COLOR_LINE : This variable takes the input of the line color.
8. WIDTH_LINE : The input for this variable is a number from 1 to 3, which is used to adjust the thickness of the line that draws the Zig Zag. WIDTH_LINE is an integer variable.
9. SHOW_LABEL : It's a boolean variable. When true, labels are displayed, and when false, label display is disabled.
10. COLOR_LABEL : The color of the labels is set in this variable.
11. SIZE_LABEL : The size of the labels is set in this variable. You should input one of the following options: size.auto, size.tiny, size.small, size.normal, size.large, size.huge.
12. Show_Support : It's a boolean variable that, when true, plots the last support line, and when false, disables its plotting.
13. Show_Resistance : It's a boolean variable that, when true, plots the last resistance line, and when false, disables its plotting.
Suggestion :
You can use the following code snippet to import Zig Zag into your code for time efficiency.
//import Library
import TFlab/ZigZagLibrary_TradingFinder/1 as ZZ
// Input and Setting
// Zig Zag Line
ShZ = input.bool(true , 'Show Zig Zag Line', group = 'Zig Zag') //Show Zig Zag
PPZ = input.int(5 ,'Pivot Period Zig Zag Line' , group = 'Zig Zag') //Pivot Period Zig Zag
ZLS = input.string(line.style_dashed , 'Zig Zag Line Style' , options = , group = 'Zig Zag' )
//Zig Zag Line Style
ZLC = input.color(color.rgb(0, 0, 0) , 'Zig Zag Line Color' , group = 'Zig Zag') //Zig Zag Line Color
ZLW = input.int(1 , 'Zig Zag Line Width' , group = 'Zig Zag')//Zig Zag Line Width
// Label
ShL = input.bool(true , 'Label', group = 'Label') //Show Label
LC = input.color(color.rgb(0, 0, 0) , 'Label Color' , group = 'Label')//Label Color
LS = input.string(size.tiny , 'Label size' , options = , group = 'Label' )//Label size
Show_Support= input.bool(false, 'Show Last Support',
tooltip = 'Last Support' , group = 'Support and Resistance')
Show_Resistance = input.bool(false, 'Show Last Resistance',
tooltip = 'Last Resistance' , group = 'Support and Resistance')
//Call Function
ZZ.ZigZag(high ,low ,bar_index ,PPZ , ShZ ,ZLS , ZLC, ZLW ,ShL , LC , LS , Show_Support , Show_Resistance )
Library

Library

ZigZag Multi [TradingFinder] Trend & Wave Lines - Structures🔵 Introduction
"Zigzag" is an indicator that forms based on price changes. Essentially, the function of this indicator is to connect consecutive and alternating High and Low pivots. This pattern assists in analyzing price changes and can also be used to identify classic patterns. "Zigzag" is an analytical tool that, by filtering partial price movements based on the specified period, can identify price waves across different time frames (short or long term).
🔵 Reason for Creation
The combination of "short term zigzag" and "long term zigzag" enhances accuracy and reduces analysis time. In a time frame, "long term zigzag" represents the main trend, while "short term zigzag" depicts short-term waves.
🔵 How to Use
After selecting the desired time frame and adding "zigzag" to the chart, begin utilization. Keep in mind to identify the main market trend from "long term zigzag" and the minor waves from "short term zigzag".
🟣 Important: Additionally, classic patterns such as HH, LH, LL, and HL can be recognized. All traders analyzing financial markets using classic patterns and Elliot Waves can benefit from the "zigzag" indicator to facilitate their analysis.
🔵 Settings
Short term zigzag : In this section, you can adjust settings such as time frame range, display mode, color, and line width of the zigzag lines.
Short term label : This section allows you to activate or deactivate the display of zigzag labels according to your needs. You can also customize their color and size.
Long term zigzag : Here, you can adjust settings for time frame range, display mode, color, and line width of zigzag lines.
Long term label : Similar to short term label settings.
The recommended time frame for "long term zigzag" is between 9 to 15, and for "short term zigzag" is between 3 to 5.
🟣 Important Notes :
Considering the different behaviors of financial markets and various time frames, it is recommended to experiment with different time frame settings when using "zigzag" to find the best settings for each symbol and time frame, thereby preventing potential errors.
🟣 Terminology Explanations :
"HH": When the price is higher than the previous peak (Higher High).
"HL": When the price is higher than the previous low (Higher Low).
"LH": When the price is lower than the previous peak (Lower High).
"LL": When the price is lower than the previous low (Lower Low).
Indicator

Indicator

ZigLibLibrary "ZigLib"
Calculate the points for ZigZag++.
You can use custom data and resolution for your ZigZag++.
Sample Usage
import DevLucem/ZigLib/1 as ZigZag
= ZigZag.zigzag(low, high)
bgcolor(direction<0? color.rgb(255, 82, 82, 80): color.rgb(0, 230, 119, 80))
line zz = line.new(z1.time, z1.price, z2.time, z2.price, xloc.bar_time, width=3)
if direction==direction
line.delete(zz )
zigzag(_low, _high, depth, deviation, backstep)
Get current zigzag points and direction
Parameters:
_low (float)
_high (float)
depth (int)
deviation (int)
backstep (int)
Returns direction, chart point 1 and chart point 2
Library

The Next Pivot [Kioseff Trading]Hello!
This script "The Next Pivot" uses various similarity measures to compare historical price sequences to the current price sequence!
Features
Find the most similar price sequence up to 100 bars from the current bar
Forecast price path up to 250 bars
Forecast ZigZag up to 250 bars
Spearmen
Pearson
Absolute Difference
Cosine Similarity
Mean Squared Error
Kendall
Forecasted linear regression channel
The image above shows/explains some of the indicator's capabilities!
The image above highlights the projected zig zag (pivots) pattern!
Colors are customizable (:
Additionally, you can plot a forecasted LinReg channel.
Should load times permit it, the script can search all bar history for a correlating sequence. This won't always be possible, contingent on the forecast length, correlation length, and the number of bars on the chart.
Reasonable Assessment
The script uses various similarity measures to find the "most similar" price sequence to what's currently happening. Once found, the subsequent price move (to the most similar sequence) is recorded and projected forward.
So,
1: Script finds most similar price sequence
2: Script takes what happened after and projects forward
While this may be useful, the projection is simply the reaction to a possible one-off "similarity" to what's currently happening. Random fluctuations are likely and, if occurring, similarities between the current price sequence and the "most similar" sequence are plausibly coincidental.
That said, if you have any ideas on cool features to add please let me know!
Thank you (:
Indicator

Zigzag Trend-based Color [SteinG]Zigzag Indicator with Trend-based Color Coding and Info Table
This indicator is forked from Trendoscope's Recursive Zigzag
The Zigzag Indicator with Trend-based Color Coding and Info Table is a powerful tool for technical analysis, designed to help you identify significant price swings, visualize trends, and analyze pivot points with ease. This advanced indicator offers enhanced functionalities and improved visual representation.
The primary purpose of the Zigzag Indicator is to identify and highlight important price reversals, commonly referred to as pivot points, in a given chart. These pivot points are essential in recognizing trend changes and potential market turning points. With the Zigzag Indicator, you can quickly identify these pivotal moments and gain valuable insights into market dynamics.
One of the standout features of this indicator is the color coding applied to the Zigzag line, which intuitively reflects the trend associated with each pivot point. The color scheme is as follows:
- Green : Indicates an upward trend, representing a bullish movement in the price.
- Lime : Represents a retracement during an upward trend, indicating a temporary pullback before the uptrend resumes.
- Red : Signifies a downward trend, indicating a bearish movement in the price.
- Orange : Represents a retracement during a downward trend, indicating a temporary bounce before the downtrend resumes.
This color coding allows you to easily visualize the prevailing market sentiment and make more informed trading decisions accordingly.
In addition to the visual representation, the Zigzag Indicator also includes an informative table that provides essential details about each pivot point. The table presents the following information for each pivot point:
1. Pivot Value : The price level at which the pivot point occurs.
2. Direction : Indicates whether the pivot point represents an upward or downward trend.
3. Fibo Ratios : Displays the Fibonacci retracement levels between two consecutive pivot points, offering insights into potential support and resistance levels.
The inclusion of this comprehensive info table enables you to analyze pivot points more effectively, understand the underlying price dynamics, and identify key trading opportunities. Indicator

Modified QQE-ZigZag [Non Repaint During Candle Building]V V V V V V V Please Read V V V V V V V
I ask Peter and he is fine, that im published this script
Tell me if you have some ideas or criticism about that sricpt
>>>>>>>>>> This is a modified Version of Peter_O's Momentum Based ZigZag <<<<<<<<<<<
This is only a test, and i want to share it with the community
It works like other ZigZags
Because Peters_O's original Version is only non repaint on closed historical Data ,
during a Candle building process it can still repaint (signal appears / 21 seconds later signal disapears / 42 seconds later signal appears again in the same candle / etc.),
but that isnt important for backtesting, its only important for realtime PivotPoints during a candle.
My goal for this zigzag was to make it absolute non repaint neither during a candle building process (current candle),
so once the signal is shown there is no chance that it disapers and shown a few seconds later again on that same candle, it can only show up one time per candle an thats it,
and that makes it absolute non repaint in all time frames.
Credits to:
==> Thanks to @glaz , for bringing the QQE to Tradingview <3
==> Thanks to @Peter_O , for sharing his idea to use the QQE as base for a Zigzag
and for sharing his MTF RSI with the Community <3
Changes:
- I changed the MTF RSI a little bit, you can choose between two version
- I changed the QQE a little bit, its now using the MTF RSI , and its using High and Low values as Source to make it absolute non repaint during a candle is building
- I added a little Divergence Calculation beween price and the MTF RSI that is used for the ZigZag
Colors :
- Green for HH / HL Continuation
- Red for LL / LH Continuation
- Yellow for Positive Divergence
- Purple for Negative Divergence
Important:
It is not possible to backtest this script correctly with historical Data, its only possible in Realtime,
because the QQE is using crossunders with RSILowSource and the QQE Line to find the Tops and,
because the QQE is using crossovers with RSIHighSource and the QQE Line to find the Bottoms,
and that means it is not possible to find the correct Time/Moment when that crossovers / crossunders happens in historical Data
=============> So please be sure you understand the Calculation and Backtest it in Realtime when you want to use it,
because i didn't published this script for real trading
=============> Im not a financial advisor and youre using this script at your own risk
=============> Please do your own research Indicator

Indicator

Zig Zag Channels [LuxAlgo]The Zig Zag indicator is a useful indicator when it comes to visualizing past underlying trends in the price and can make the process of using drawing tools easier. The indicator consists of a series of lines connecting points where the price deviates more than a specific percentage from a maximum/minimum point ultimately connecting local peaks and troughs.
This indicator by its very nature backpaints by default, meaning that the displayed components are offset in the past.
🔶 USAGE
The Zig Zag indicator is commonly used to returns points of references for the usage of specific drawing tools, such as Fibonacci retracements, fans, squares...etc.
The proposed indicator estimates peaks and troughs by using rolling maximums/minimums with a window size determining their significance. This window size approach allows us to have an indicator that works with a certain regularity no matter the scale of the price, something the percentage-based approach struggles with. Additionally, one upper and lower extremity are displayed, highlighting the price point that deviates the most from the Zig Zag lines.
A common usage also includes the easy determination of Elliot wave patterns in the price.
The Zig Zag indicator above highlights a downtrending motive wave.
🔹 Extremities
The novel approach taken by this Zig Zag indicator is the addition of two extremities derived from the distance between the price and the Zig Zag line, thus returning channels. It is uncommon seeing extremities in Zig Zag indicators since the line connecting peaks and troughs has rarely any other utility than seeing trend variations with more clarity and is not meant to provide an accurate estimate of underlying local trends in the price.
This channel can be useful to study the potential relationship between underlying trends and the Zig Zag line. A low width between the Zig Zag and the upper extremity indicates price variations mostly located below the Zig Zag while equal width indicates more linear trends.
When the indicator is extended to the last line, the extremities provide potential support and resistances, thus making this indicator able to forecast price variations.
🔶 SETTINGS
Length: Determines the significance of the detected peaks and troughs.
Extend To Last Bar: Extend the most recent line to the most recent closing price value.
Show Extremities: Displays the extremities.
Show Labels: Display labels highlighting the high/low prices located at peaks and troughs.
🔹 Style
Upper Extremity Color: Color of the upper extremity displayed by the indicator.
Zig Zag Color: Color of the ZigZag lines.
Lower Extremity Color: Color of the lower extremity displayed by the indicator.
Indicator

Indicator

Indicator
