> *Manfred Dürschner applied the Nyquist-Shannon sampling theorem to cascaded moving averages: the second smoothing period must not exceed half the first, or you get aliasing artifacts. Respect the theorem and the ghost signals disappear.*
- NYQMA combines a primary LWMA (Linear Weighted Moving Average) with a secondary LWMA applied to the first, using lag-compensating extrapolation: $\...
NYQMA combines a primary LWMA (Linear Weighted Moving Average) with a secondary LWMA applied to the first, using lag-compensating extrapolation: $\text{NYQMA} = (1+\alpha) \cdot \text{MA}_1 - \alpha \cdot \text{MA}_2$, where $\alpha = N_2 / (N_1 - N_2)$. The Nyquist constraint $N_2 \leq \lfloor N_1/2 \rfloor$ ensures the second smoothing does not introduce aliasing artifacts into the output. This produces a lag-reduced moving average grounded in sampling theory rather than ad-hoc coefficient tuning. Streaming update is O(1) per bar via composed Wma instances; batch mode uses stackalloc/ArrayPool with FMA in the extrapolation loop.
Dr. Manfred G. Dürschner published NYQMA in *Gleitende Durchschnitte 3.0* ("Moving Averages 3.0"), a German-language work that applies rigorous signal-processing theory to financial moving average design. His key insight: cascading two smoothing operations is mathematically equivalent to sampling a continuous signal at two rates. The Nyquist-Shannon sampling theorem (Shannon 1949, Nyquist 1928) dictates that the second rate cannot exceed half the first without introducing aliasing.
The lag compensation formula $(1+\alpha) \cdot \text{MA}_1 - \alpha \cdot \text{MA}_2$ is structurally identical to DEMA and GDEMA, but with two critical distinctions: (a) both constituent MAs are LWMAs, not EMAs, giving the filter a finite impulse response with bounded memory; (b) the gain factor $\alpha$ is derived from the period ratio $N_2/(N_1 - N_2)$ rather than being a free parameter, grounding the extrapolation strength in sampling theory.
Most double-smoothed moving averages (DEMA, TEMA, T3) use the same MA period for both stages. Dürschner's contribution is recognizing that the second stage period is a free design parameter, but one constrained by the Nyquist limit. When $N_2 = N_1$ (the DEMA case), the constraint is violated by definition. When $N_2 = \lfloor N_1/2 \rfloor$ (the maximum legal Nyquist value), lag cancellation is maximized without aliasing. Smaller $N_2$ values trade less lag reduction for more conservative anti-aliasing margin.
The primary WMA needs $N_1$ bars to fill; the secondary WMA then needs $N_2$ bars of valid WMA1 output, but the first WMA1 output arrives at bar 1, so the total warmup is $N_1 + N_2 - 1$.
| Computational cost | 9 | Two O(1) WMA updates + one FMA |
| Parameter sensitivity | 8 | Two intuitive parameters with physical meaning |
## Validation
NYQMA has no direct equivalent in external libraries (TA-Lib, Skender, Tulip, Ooples). Validation is performed via component consistency: verifying that the composed output matches the explicit formula.
The $1 \times 10^{-6}$ tolerance for batch vs streaming reflects expected floating-point divergence from different evaluation order (span-based batch vs composed instance streaming).
## Common Pitfalls
1.**Integer division in alpha calculation.** The original PineScript used integer types for `n2 / (period - n2)`, yielding 0 for all typical parameters (e.g., `21/68 = 0` in integer arithmetic). The fix: cast to float before division. Impact: complete failure of lag compensation when alpha truncates to zero.
2.**Nyquist period exceeding half the primary period.** Violates the sampling theorem. The implementation clamps silently, but users who set $N_2 > N_1/2$ and expect that exact value will get a different (clamped) indicator. Document the clamping behavior.
3.**Overshoot on sharp reversals.** The $(1+\alpha)$ gain factor amplifies the primary WMA relative to the smoothed secondary. On V-shaped reversals, NYQMA will overshoot more than a raw WMA. For $\alpha \approx 1$ (maximum Nyquist), the overshoot approaches DEMA levels.
4.**Warmup period miscalculation.** The total warmup is $N_1 + N_2 - 1$, not $\max(N_1, N_2)$ or $N_1 \cdot N_2$. Before warmup completion, the filter output is valid but numerically colder (reduced effective smoothing).
5.**Confusing NYQMA with PMA.** PMA uses $\text{WMA}(\text{src}, N)$ and $\text{WMA}(\text{WMA}(\text{src}, N), N)$ (same period twice) with $\alpha = 1$ fixed. NYQMA uses different periods and derives $\alpha$ from the period ratio. They converge only when $N_2 = N_1/2$ and rounding is ignored.
6.**Batch vs streaming floating-point divergence.** The batch path computes WMA1 and WMA2 as separate span passes, while streaming composes two Wma instances feeding one into the other. Different accumulation order produces divergence around $10^{-8}$ to $10^{-6}$ on 500-bar series. This is expected and not a bug.
7.**Using System.Random for test data.** Per project protocol, test data must use GBM (Geometric Brownian Motion) helpers. Random walk paths from System.Random lack the drift and volatility characteristics of financial time series.