zigzag

forge.tafunctionSince Forge API 1
Functionpython
forge.ta.zigzag(high: ArrayLike,low: ArrayLike,close: ArrayLike,depth: int = 12,backstep: int = 3,atr_period: int = 14,atr_mult: float = 1.0) -> dict[str, np.ndarray]

Swing highs and lows, written only once a reversal confirms them.

Parameters

NameTypeDefault
highArrayLike
lowArrayLike
closeArrayLike
depthint12
backstepint3
atr_periodint14
atr_multfloat1.0

Indicator: ZigZag

up and down hold the swing price on the bar that confirmed it, offset the number of bars back to the swing, pivot the last confirmed swing price carried forward and direction +1 after a confirmed low and -1 after a confirmed high. A reversal confirms a swing once it is at least atr_mult average true ranges (Wilder's) from it. The swing still pending at the end is never written, so no value is ever revised.

Classpython
forge.ta.ZigZag(**inputs: Any) -> None

Swing highs and lows, each shown only once a reversal has confirmed it.

Inputs

NameTypeDefaultRange
depthint122 to 200
backstepint30 to 100
atr_periodint141 to 500
atr_multfloat10.1 to 10

A bar is a low (high) candidate when its low (high) is the lowest (highest) of the last depth bars. A candidate is final after backstep more bars, once weaker candidates of the same kind within backstep bars are cleared.

One swing is pending at a time. A stronger candidate of the same kind replaces it. An opposite candidate at least atr_mult average true ranges away confirms it.

The confirmed swing is written on the confirming bar: up or down holds its price and offset the bars back to it. pivot is the last confirmed price, direction is 1 after a low and -1 after a high. The swing pending at the end is never written.