ZigZag's "repainting" is not a bug — it is a direct result of how the indicator works. This indicator always needs to wait for price to move far enough in the opposite direction before it can go back and confirm the previous pivot. Before that confirmation happens, the last line segment keeps adjusting its start and end points as price changes. Understanding this is more practical than searching for a "non-repainting version" — a true non-repainting version simply changes the confirmation logic to trigger later, at the cost of slower signals.

A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!
Where Repainting Happens: The Last Leg
The standard ZigZag algorithm works by connecting significant highs and lows while filtering out moves that do not reach the threshold. The issue lies in the "confirmation" step.
TradingView's official documentation explains it clearly: when a new extreme appears in the same direction, the previous pivot is "invalidated", and the latest line segment is anchored directly to the new extreme. For example, if ZigZag currently shows a high at point A, price pulls back, but then makes a higher high at point B, then point A is deleted and the line segment's endpoint becomes B.
This is the source of "repainting". Until a reversal is confirmed, the endpoint of the last line segment is always in a pending state. The Python version of the ZigZag documentation even includes a warning: the last line segment "will always repaint back to the last known pivot".
Why This Happens: Threshold vs. Confirmation Order
ZigZag identifies pivots based on whether price has moved far enough in the opposite direction from an extreme to reach a preset threshold. Common thresholds in crypto markets are 5% or 10%. But until price actually moves that far, the indicator cannot know whether the current extreme will be surpassed.
A concrete example: suppose you use a 5% threshold on the 4-hour chart. Bitcoin rises from 60,000 to 63,000 (high A), then pulls back to 61,000. At this point ZigZag may draw a temporary downward line from A because it detects a pullback of more than 5%. But if price does not continue falling and instead rebounds and breaks above 63,000 to reach 64,000, then A is no longer a valid high. ZigZag deletes A and moves the line segment's endpoint to 64,000.
This process repeats in real-time until price actually makes a deep enough pullback that locks in the previous extreme.
The Real Cost of "Non-Repainting" Versions
There are many ZigZag scripts on TradingView labeled "Non-Repaint". These versions work by only drawing signals after the bar closes and the pivot is confirmed, and they require the closing price to break a structural level before triggering.
One script's description states it plainly: all labels and alerts are gated by barstate.isconfirmed, and higher timeframe filtering uses lookahead_off to ensure that historical display matches what is seen in real time.
But there is a cost. An author who specifically studied real-time ZigZag confirmation statistics pointed out that standard ZigZag backtests look good because they calculate returns starting from the "absolute low or high" — but a trader could not have entered at that moment because the indicator had not yet triggered. Non-repainting versions change the starting point of return calculations to the "confirmation bar's closing price" and introduce a metric called Lag Cost to quantify the actual loss caused by signal delay.
In other words, a non-repainting ZigZag is not a "version without the repainting problem" — it is a version that accepts a fixed confirmation delay, trading lag for certainty.
Practical Ways to Handle It
If you use ZigZag to help identify trend structure or find support and resistance, you do not need to abandon it because of repainting. More practical approaches include:
Treat the last line segment as "tentative" rather than "confirmed". Do not base entry decisions on the endpoint of the last line segment until price has moved far enough in the opposite direction or has confirmed on a closing basis. Gate's wiki guide also reminds users that ZigZag is a lagging indicator, better suited for analyzing historical structure than predicting the future.
If you need backtesting or automated signals, define your confirmation rules clearly. Either use a non-repainting version and accept the lag, or require "pivot confirmation + N bars" in your code before triggering. Backtesting directly based on the real-time state of ZigZag's last line segment will produce results that seriously deviate from actually executable performance.
Parameter choices affect how often repainting occurs. Lower thresholds (like 1–3%) make ZigZag more sensitive, and the last line segment gets updated or deleted more frequently. Higher thresholds (like 10–15%) produce more stable signals but with more obvious lag. There is no "best parameter" — it depends on the timeframe you are analyzing and the confirmation delay you are willing to accept.

A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!
References
- Stock Indicators for Python·Zig Zag, page published or updated: 2024-11-02; verified: 2026-10-08.
- TradingView·Zigzag indicator, page date not specified; verified: 2026-10-08.
- TradingView·AlgoSentry ZigZag Trend [Non-Repaint], page published or updated: 2026-06-16; verified: 2026-10-08.
- TradingView·ZigZag with Real-Time Confirmation Stats, page published or updated: 2026-07-20; verified: 2026-10-08.
- Gate Wiki·Zig Zag Indicator in Crypto: Complete Guide to Detecting Trend Lines, page published or updated: 2026-01-12; verified: 2026-10-08.
- Gate Wiki·Complete Guide to Zig Zag Indicator: How to Find Cryptocurrency Trend Lines, page published or updated: 2026-01-12; verified: 2026-10-08.
- MQL5·weird behaviour of zigzag indicator, page published or updated: 2025-03-10; verified: 2026-10-08.
- Sierra Chart·Zig Zag Displaying Incorrectly, page published or updated: 2018-03-26; verified: 2026-10-08.
- TradingView·Zigzagpattern, page date not specified; verified: 2026-10-08.
- Wealth-Lab·ZigZag-indicator-first-pivot-point-calculation, page published or updated: 2025-11-12; verified: 2026-10-08.


