The Jurik Moving Average (JMA) is an advanced adaptive moving average that provides superior smoothing with minimal lag. It dynamically adjusts its response based on market volatility using a sophisticated multi-stage algorithm involving volatility distribution analysis and adaptive IIR filtering.
## Core Concepts
- **Volatility-Based Adaptation:** JMA uses a 128-sample volatility distribution with trimmed mean to estimate market conditions.
- **Dynamic Exponent:** The smoothing factor adjusts automatically based on the ratio of local deviation to reference volatility.
- **Phase Control:** Fine-tunes the balance between responsiveness and stability (-100 to +100).
- **Minimal Lag:** Tracks price action closely while filtering noise, outperforming traditional moving averages.
- **Warmup Period:** JMA requires approximately `20 + 80 × period^0.36` bars to stabilize its internal volatility distribution.
## Parameters
| Parameter | Default | Description |
|-----------|---------|-------------|
| Period | 10 | The base period for the moving average calculation. |
| Phase | 0 | Phase shift (-100 to 100). Negative values reduce lag but may increase overshoot. Positive values increase smoothing and stability. |
| Power | 0.45 | Legacy parameter kept for API compatibility. Not actively used in current implementation. |
## Algorithm
JMA employs a sophisticated multi-stage process:
1.**Adaptive Envelope:** Maintains upper and lower bands that adapt to price movement using dynamic smoothing.
2.**Local Deviation:** Calculates the maximum absolute distance between price and the envelope bands.
3.**Short-Term Volatility:** Computes a 10-bar simple moving average of the local deviation.
4.**Volatility Distribution:** Maintains a rolling 128-sample buffer of the short-term volatility values.
5.**Reference Volatility:** Calculates a trimmed mean of the volatility distribution:
- Sorts the 128 samples
- Takes the central 65 samples (indices 32-96)
- Computes their mean, effectively removing outliers from both tails
6.**Dynamic Exponent:** Derives an adaptive smoothing factor:
- Raises ratio to power `p = max(logParam - 2.0, 0.5)`
- Clamps result between 1.0 and `logParam`
7.**2-Pole IIR Filter:** Applies a dual-pole Infinite Impulse Response filter using the dynamic exponent to produce the final JMA value with controlled phase shift.
This implementation is a high-fidelity port of the reverse-engineered JMA algorithm found in AmiBroker and MT4, optimized for performance using logarithmic transformations for power calculations.
- **IsHot:** Returns `true` when JMA has processed enough bars to stabilize its internal volatility distribution (approximately `20 + 80 × period^0.36` bars).
- **Last:** The most recent calculated JMA value.
- **Name:** Identifier string in format `"Jma(period,phase,power)"`.