ZigZag Supertrend
Jul 22, 2021

The ZigZag Supertrend indicator is a trend-following tool that calculates Supertrend levels based on ZigZag pivot points rather than traditional high/low prices or simple lookback periods. By anchoring trend detection to significant structural swings, it aims to provide more robust trailing stop levels and clearer trend identification.
Usage
The indicator can be used to identify current market trends and potential reversal points. When the price is above the green line, the market is considered to be in a bullish trend; when the price is below the red line, it is in a bearish trend.
- Trend Reversals: A shift from red to green (or vice versa) indicates a change in trend direction.
- Trailing Stops: The levels can act as dynamic support and resistance zones for managing exits.
- Wiggle Room: By using ATR adjustments on top of the ZigZag pivots, the tool allows for "zones" of support and resistance, preventing premature exits during minor pullbacks.
Details
Unlike standard Supertrend versions that use the median price and ATR, this script identifies high and low pivot points using a ZigZag algorithm. It stores these pivots in an array to determine the range for the Supertrend calculation. The script is optimized for performance by deleting older lines immediately, ensuring it runs efficiently on lower timeframes without hitting line limits or calculation errors.
Settings
- Source: Determines the price data used for the ZigZag calculations (default is Close).
- Length: The lookback period used to identify the initial pivot highs and lows.
- History: Specifies the number of ZigZag segments to be kept in memory for determining the high/low range.
- Wait for Confirmation: When enabled, the tool only considers confirmed ZigZag pivots and ignores the "repainting" leg currently forming.
- Wait for Close: If checked, the Supertrend direction updates based on the Close price crossing the level. If unchecked, it uses High/Low prices.
- ATR Periods: The lookback period for the Average True Range calculation used to add a buffer to the pivots.
- ATR Multiplier: Scales the ATR value to increase or decrease the distance between the pivots and the Supertrend line.
FAQ
How do I use the ZigZag Supertrend?
You can use it as a primary trend filter or a trailing stop-loss mechanism. It helps you stay in a trend until a significant structural pivot is breached.
Does this indicator repaint?
The ZigZag logic itself update as new highs/lows are formed, but the "Wait for Confirmation" setting helps mitigate issues by only considering finalized pivot points for the Supertrend calculation.
How can I access this indicator?
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.