Skip to content
All library documents

Building a Reversible ZigZag Indicator with Point and Percentage Thresholds

Article ProRealCode

Summary

The document presents an array-based ZigZag indicator for plotting alternating swing highs and lows. A configurable threshold can be expressed in pips or as a percentage; the percentage mode uses the previous day’s close as its reference, which the author says reduces instability and graphical artifacts at very small thresholds. A segment setting controls how many recent high-low pairs are retained and drawn.

The logic updates a candidate extreme while price continues in the same direction, then confirms a reversal after price moves by at least the selected threshold. The current, unfinished leg is drawn as dotted, while stored legs are shown as solid segments. The author reports that the output is almost identical to the platform indicator in both point and percentage modes, but supplies no formal validation or trading results. Since the latest candidate extreme can change until a reversal threshold is reached, the display is retrospective and should not be treated as a standalone predictive signal.

Key ideas

  • The indicator alternates between tracking candidate highs and lows and confirms a swing after a threshold reversal.
  • The threshold can use fixed pip distance or a percentage of the previous day’s close.
  • A segment parameter limits how many recent completed swing pairs are displayed.
  • The active leg is distinguished visually from the stored completed legs.
  • The author reports visual agreement with a platform indicator but provides no backtest or predictive evidence.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.