Investment Studio > Expressions > Functions > Indicator > ZZI

float array[*][2] zzi(float array[*][2] dc, float relative_separation_threshold = 10%, boolean logarithmic = FALSE)

Returns a two-column array containing dates (first column) and corresponding Zig-Zag Indicator (ZZI) values (second column). Given n input rows in dc, n rows are returned.

dc is a two-column array containing dates (first column) and corresponding daily closes (second column). The array is assumed to be time-sorted, with earlier dates preceding later dates.

Automatic type conversion allows the use of date strings as arguments instead of explicit date values.

relative_separation_threshold > 0 determines when ZZI will consider ending the current trendline and starting a new one. This requires that a daily close be an extrememum (local minimum or local maximum) separated by more than the specified relative amount from the previous, opposite extremum. If omitted, relative_separation_threshold defaults to 10%.

logarithmic is used to select the kind of trendline interpolation. If FALSE, linear interpolation is used (trendlines will look straight in linear charts, curved in logarithmic charts). If TRUE, logarithmic interpolation is used (trendlines will look straight in logarithmic charts, curved in linear charts). If omitted, logarithmic defaults to FALSE.

In Chart and Graph objects, use the built-in symbol ISLOG to find out whether the vertical axis is logarithmic (TRUE) or not (FALSE).

Interpretation

ZZI is a trend-fitting tool. It creates a piecewise linear (logarithmic = FALSE) or logarithmic (logarithmic = TRUE) interpolation of prices between significant trend reversal points. If a ZZI leg is up, the next leg is always down, and vice versa (hence the name). This is useful as a way to get "the big picture". For those so inclined, it can also be a starting point for Elliot wave analysis.

The endpoints of the trendlines created by ZZI are local extrema of opposite kind (i.e. an alternation of minima and maxima) separated by relative_separation_threshold or more. The first and last quote are special cases: to ensure that there is a ZZI value for all quote dates, they are always the ZZI's start and end points.

It's important to understand the implications of this procedure for the last leg in the ZZI: it can (and most likely will) change as soon as new quotes are added. This is radically different from the behaviour of most other indicators, which do not revise their old values based on new quotes. The perfect hindsight displayed by ZZI is just that, hindsight. Do not misinterpret it as evidence of predictive power!

For a real life example, consider Corel (NASD:CORL) from January 1 to December 31, 2001:

The top chart shows prices in standard candlestick form. The bottom chart shows daily closes in gray, 5% ZZI in red, 10% ZZI in green, 15% ZZI in blue and 20% ZZI in black. "Faster" (lower threshold) ZZIs are drawn on top of "slower" (higher threshold) ones, so partial overlaps cause the latter to be hidden when they share endpoints with the former.

Example

Assuming standard US date format settings,

=zzi({{"1/1/1990", 12}, {"1/2/1990", 13}, {"1/3/1990", 10}, {"1/4/1990", 11}})

returns {{32874, 12}, {32875, 11}, {32876, 10}, {32877, 11}}. 32874 is the date code for 1/1/1990; 12 is the first ZZI point = the first quote, as always. 32875 is the date code for 1/2/1990; 11 is the second ZZI point: we are using defult arguments, so the separation threshold is 10%, and the day's quote (13) is not sufficiently separated from the latest extremum (the starting point, 12) to pass the threshold condition. Therefore, ZZI is interpolating toward the next extremum. That's the third quote: 10 is sufficiently separated from 12 to pass the 10% threshold; since it's a local minimum, it also qualifies as a turning point, and becomes the endpoint of the first trendline. As always, the last ZZI point = the last quote.

See also ema, forecast, growth, intercept, linest, logest, ma, slope, trend.