## EMA with lag compensation via a zero-lag signal
ZLEMA takes a standard EMA and feeds it a **zero-lag signal**: current price minus a lagged price. This produces a smoother that responds faster than EMA without going fully raw. It is not magic. It shifts some lag into controlled overshoot.
## Historical Context
ZLEMA is a widely used variation on EMA intended to reduce delay without abandoning exponential smoothing. It appears in multiple technical analysis toolkits and is often described as a "predictive EMA." The prediction is simple: extrapolate the current price by subtracting a lagged value.
## Architecture & Physics
### Pipeline
1.**Lag estimate**
$$\text{lag} = \max(1, \text{round}((N-1)/2))$$
2.**Zero-lag signal**
$$s_t = 2 \cdot x_t - x_{t-\text{lag}}$$
3.**EMA smoothing**
$$\text{ZLEMA}_t = \text{EMA}(s_t, \alpha)$$
### Warmup compensation
ZLEMA uses EMA bias compensation during warmup:
$$y_t^{*} = \frac{y_t}{1 - (1 - \alpha)^t}$$
This avoids the early-stage bias toward zero and makes the first values usable.
The zero-lag signal is a forward estimate. It can overshoot when price reverses sharply. This is expected behavior.
2.**Period semantics**
ZLEMA uses EMA alpha; the lag term is derived from period but not equivalent to a window length. Do not compare ZLEMA period directly to SMA window length.
3.**Warmup discipline**
Use `IsHot` / `WarmupPeriod` before acting on signals. Early values are bias-corrected but still unstable.