ZigZag KB AutoFib
Jun 2, 2026

The ZigZag KB AutoFib indicator automates the identification and plotting of Fibonacci retracement levels based on ZigZag price movements to highlight high-probability trade setups. This tool streamlines the detection of "Golden Pocket" zones, providing clear entry and Take Profit (TP) targets for down-swing recoveries.
Usage
The Usage section describes how the script can be used to identify trend reversals and price targets. The indicator focuses on A→B down-swings (where A is a swing high and B is a swing low) to project recovery levels.
- Recent Setup: The tool automatically identifies the most recent confirmed down-swing and plots two primary zones: the Entry Zone (based on specific Fibonacci ratios) and the Take Profit Zone.
- Largest Swing: Users can visualize the largest down-swing within the visible chart range, shown as dimmed boxes, to understand the broader market context.
- Trade Confirmation: The indicator includes built-in filters to refine entries. A bullish triangle is plotted when price closes above the Entry Zone high while satisfying moving average and volume conditions.
- History Tracking: Past setups are archived and displayed in a dimmed format, allowing traders to review how previous zones reacted to price action.
Details
The script utilizes the official TradingView ZigZag library to ensure stable and predictable pivot detection. A pivot is confirmed only when price deviates by a user-defined percentage from the previous point, preventing noise from creating false setups.
- Strategy Math: The zones are calculated using the range (A - B). The Entry Zone is defined between 0.32 and 0.382 of the range above point B. The TP Zone is defined between 0.618 and 0.68 of the range above point B.
- Exit Logic: Take Profit is triggered when the high price reaches the TP Zone. A Stop Loss (SL) signal is generated if the price closes below both the 9-period and 21-period EMAs while in a trade.
- Lifecycle Management: Active setups are moved to history once the TP target is met or when a new swing low (B) is formed, ensuring the chart remains focused on the most relevant price data.
Settings
Pivot Detection
- Price Deviation (%): The percentage price must move to confirm a new ZigZag pivot. Higher values filter out smaller price fluctuations.
- Min Bars Between Pivots: The minimum bar count required between a high and a low pivot.
Fibonacci Levels (KB strategy)
- Entry Zone — Low/High: Defines the Fibonacci retracement levels for the entry box (default 0.32 - 0.382).
- TP Zone — Low/High: Defines the Fibonacci retracement levels for the Take Profit box (default 0.618 - 0.68).
Moving Averages & Filters
- Show EMA 9 / EMA 21: Toggles the visibility of the trend-following exponential moving averages.
- Require Close > EMA 9 AND EMA 21: When enabled, entry signals only appear if price is above both EMAs.
- Require Volume > 1.2× 20-bar Avg: Adds a volume exhaustion/expansion filter to entry signals.
Display & History
- Show Largest Swing: Toggles the display of the largest historical swing in the current view.
- Show Past Setups: Enables or disables the display of archived historical zones.
- Max Past Setups: Limits the number of historical setups drawn on the chart.
- Show ZigZag Line (debug): Displays the underlying ZigZag lines used for calculation to assist in tuning deviation settings.
FAQ
How do I interpret the colored boxes? The Entry Zone (typically lower) represents the area where price is expected to find support before moving higher. The TP Zone (typically higher) represents the primary objective for the recovery move.
Why are some boxes dimmed? Dimmed boxes represent either "History" (setups that have already reached their target or been superseded) or the "Largest Swing" reference, which provides macro context behind the active setup.
How can I access the ZigZag KB AutoFib? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.