Zig Zag Channels
length = 100 | extend = true Overview
Zig Zag Channels builds a channel around a zig-zag style structural path and returns middle, upper, and lower lines. It is useful when you want a more structured channel than a plain moving envelope, especially for swing-oriented chart work.
In VectorTA the indicator works on open-high-low-close input, supports direct slice execution and batch sweeps over the main structural lookback while keeping the extend toggle explicit. That makes it a useful channeling tool for pattern overlays and swing-distance studies.
Defaults: `length = 100` and `extend = true`.
Implementation Examples
Run Zig Zag Channels on direct OHLC slices or on candle data with the default extension behavior.
use vector_ta::indicators::zig_zag_channels::{
zig_zag_channels,
ZigZagChannelsInput,
ZigZagChannelsParams,
};
let output = zig_zag_channels(&ZigZagChannelsInput::from_slices(
&open,
&high,
&low,
&close,
ZigZagChannelsParams::default(),
))?;
println!("middle = {:?}", output.middle.last());
println!("upper = {:?}", output.upper.last());API Reference
Input Methods ▼
ZigZagChannelsInput::from_candles(&Candles, ZigZagChannelsParams)
-> ZigZagChannelsInput
ZigZagChannelsInput::from_slices(&[f64], &[f64], &[f64], &[f64], ZigZagChannelsParams)
-> ZigZagChannelsInput
ZigZagChannelsInput::with_default_candles(&Candles)
-> ZigZagChannelsInputParameters Structure ▼
pub struct ZigZagChannelsParams {
pub length: Option<usize>,
pub extend: Option<bool>,
}Output Structure ▼
pub struct ZigZagChannelsOutput {
pub middle: Vec<f64>,
pub upper: Vec<f64>,
pub lower: Vec<f64>,
}Validation, Warmup & NaNs ▼
- Open, high, low, and close inputs must share the same non-zero length and contain enough valid data for the resolved
length. - The
extendtoggle changes whether the structural channel is projected forward after the last confirmed pivot. - There is no streaming API for this indicator; it is evaluated over complete OHLC windows.
- Batch mode validates the lookback range before generating the channel matrix.
Builder, Streaming & Batch APIs ▼
ZigZagChannelsBuilder::new()
.length(usize)
.extend(bool)
.kernel(Kernel)
.apply(&Candles)
.apply_slices(&[f64], &[f64], &[f64], &[f64])
ZigZagChannelsBatchBuilder::new()
.length_range(start, end, step)
.extend(bool)
.apply_slices(&[f64], &[f64], &[f64], &[f64])Python Bindings
Python exposes direct and batch helpers for the middle, upper, and lower zig-zag channel lines.
from vector_ta import zig_zag_channels, zig_zag_channels_batch
single = zig_zag_channels(open, high, low, close, length=100, extend=True)
batch = zig_zag_channels_batch(open, high, low, close, length_range=(40, 120, 20), extend=True)JavaScript/WASM Bindings
The WASM layer exposes direct, batch, allocation, and into-buffer helpers for zig-zag channel calculations.
import init, { zig_zag_channels_js, zig_zag_channels_batch_js } from "vector-ta-wasm";
await init();
const single = zig_zag_channels_js(open, high, low, close, 100, true);
const batch = zig_zag_channels_batch_js(open, high, low, close, {
length_range: [40, 120, 20],
extend: true,
});CUDA Bindings (Rust)
Additional details for the CUDA bindings can be found inside the VectorTA repository.
Performance Analysis
Across sizes, Rust CPU runs about 1.14× faster than Tulip C in this benchmark.
AMD Ryzen 9 9950X (CPU) | NVIDIA RTX 4090 (GPU)
Related Indicators
Average Directional Index
Technical analysis indicator
Average Directional Movement Index Rating
Technical analysis indicator
Alligator
Technical analysis indicator
Aroon
Technical analysis indicator
Aroon Oscillator
Technical analysis indicator
Chande Momentum Oscillator
Technical analysis indicator