Smart ZigZag
Jun 3, 2026

The Smart ZigZag indicator identifies significant price structural points by connecting highs and lows through a statistical, volume-weighted framework to filter market noise and highlight trend reversals. Unlike traditional ZigZag tools that rely on fixed percentages, this script employs dynamic volatility thresholds to adapt to changing market conditions.
Usage
The Usage section focuses on how the script interprets market structure and how settings influence the visual output.
The indicator connects major price pivots with trend lines, using green for upward legs and red for downward legs. Traders can use these lines to identify support and resistance levels, trend direction, and market cycles. Labels are placed at each pivot point to provide immediate quantitative data.
- Identifying Trends: A new leg is only formed when price deviates significantly from the previous pivot, ensuring that minor fluctuations are ignored.
- Pivot Confirmation: The script uses a "Backstep" mechanism, meaning a specific number of bars must pass before a new trend direction is eligible for confirmation, preventing erratic signals in tight ranges.
- Information Overlay: Users can customize labels to show the price level, the percentage change between pivots, or the statistical deviation (Z-Score) used to trigger the move.
Details
The Smart ZigZag uses a sophisticated statistical engine rather than static inputs to determine when a trend has shifted.
- Baseline Selection: The script calculates a baseline using Volume Weighted Average Price (VWAP). If volume data is unavailable (common in certain Forex or Crypto pairs), it automatically switches to an Arnaud Legoux Moving Average (ALMA).
- Volatility Thresholds: It calculates the Standard Deviation of price relative to the baseline. This value is multiplied by a Z-Score threshold to create a dynamic "zone." A reversal is only triggered if price breaks outside this statistical boundary.
- Autotune Engine: When enabled, the script analyzes the volatility distribution (skewness) of the last 200 candles. It automatically adjusts the Z-Score and Backstep requirements—widening them during high volatility to avoid "whipsaws" and tightening them during low volatility to capture breakouts early.
- Array Management: The script utilizes internal arrays to manage historical pivot prices and bar coordinates, ensuring efficient real-time updates and historical accuracy.
Settings
Dynamic Backstep Range
- Minimum Backstep: The minimum number of bars required between two pivot points.
- Maximum Backstep: The upper limit for the backstep when the Autotune engine detects high volatility.
Main Statistical Engine
- Sample Period (StDev/Baseline): The lookback period used for calculating the baseline (VWAP/ALMA) and the standard deviation.
- Manual Z-Score Threshold: The sensitivity of the reversal trigger when Autotune is disabled. Higher values require larger price moves to form a new leg.
- Autotune Algorithmic Engine: Enables the automatic normalization of parameters based on the last 200 bars of volatility data.
Appearance and Labels
- Label Data: Determines what information is displayed on pivot labels (Price, %, Deviation, or None).
- Up/Down Color: Sets the color for bullish and bearish ZigZag legs and labels.
- Line Style/Thickness: Customizes the visual weight and pattern of the trend lines.
Dashboard Settings
- Show Dashboard: Toggles the visibility of the on-screen information table.
- Position: Moves the dashboard to different corners of the chart.
- Progress Bar/Impulse Colors: Customizes the colors used in the dashboard to represent "Locked" trends versus "Impulse" movements.
FAQ
How do I interpret the percentage shown on the labels? The percentage represents the price change from the previous pivot point to the current one, indicating the magnitude of the trend leg.
Why does the ZigZag line change its endpoint in real-time? The current leg is "dynamic." It will continue to stretch to new highs (in an uptrend) or new lows (in a downtrend) until a valid statistical reversal occurs in the opposite direction.
How can I access the Smart ZigZag? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Unlock Unlimited Access to the LuxAlgo Library
Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

