JERK measures the rate of change of acceleration—called "jerk" in physics. As the third derivative, it detects changes in momentum dynamics before they appear in acceleration, velocity, or price. A positive jerk means acceleration is increasing; negative means acceleration is decreasing. This O(1) streaming implementation uses dual FMA optimization and SIMD batch processing for four-point calculations.
## Historical Context
The third derivative (jerk) appears in mechanical engineering, robotics, and ride comfort analysis. Roller coasters are designed to minimize jerk; elevators smooth their motion to reduce it. In financial markets, jerk reveals sudden shifts in how fast the trend is accelerating or decelerating.
While first and second derivatives see wide use in technical analysis (momentum, ROC, acceleration indicators), the third derivative remains underutilized. This is partly computational—four consecutive points are needed—and partly interpretive: jerk is abstract. Yet it provides the earliest mathematical signal of trend character change.
Consider: price is rising, acceleration is positive (strong uptrend). If jerk turns negative, acceleration will soon decrease, then velocity will peak, then price will top. Jerk leads the entire sequence.
QuanTAlib implements JERK as the discrete third difference with dual FMA optimization, SIMD batch processing, and full bar correction support.
## Architecture & Physics
JERK computes the third finite difference with four-point history:
### 1. Third Difference Operation
The fundamental operation:
$$
J_t = V_t - 3V_{t-1} + 3V_{t-2} - V_{t-3}
$$
This is algebraically equivalent to:
$$
J_t = A_t - A_{t-1}
$$
where $A$ is the second derivative (acceleration).
### 2. Dual FMA Optimization
The formula uses two Fused Multiply-Add operations:
$$
\text{term}_1 = \text{FMA}(-3, V_{t-1}, V_t)
$$
$$
\text{term}_2 = \text{FMA}(3, V_{t-2}, -V_{t-3})
$$
$$
J_t = \text{term}_1 + \text{term}_2
$$
This structure reduces rounding error and leverages pipelined FMA units on modern CPUs.
### 3. State Management
State consists of:
-`Prev1`: The previous input value $V_{t-1}$
-`Prev2`: The value before that $V_{t-2}$
-`Prev3`: The value before that $V_{t-3}$
-`LastValidValue`: Last known finite value for NaN/Infinity substitution
-`Count`: Number of values processed (0, 1, 2, 3, or 4+)
The indicator becomes "hot" (fully warmed up) after 4 values.
1.**Catastrophic Noise Sensitivity**: Third derivatives amplify noise cubically. A 1% random wiggle becomes a wild jerk spike. Pre-smooth the input significantly (14+ period EMA minimum) before computing JERK.
2.**Scale Dependency**: JERK output scales with input magnitude cubed. A $100 stock has 1,000,000× larger jerks than a $1 stock. Normalization is essential for cross-instrument comparison.
3.**Warmup Period**: JERK requires 4 values to produce meaningful output. The first three outputs are always 0.
4.**Abstract Interpretation**: Jerk doesn't have an intuitive physical meaning for most traders. Use it as an early warning signal, not a direct trading trigger.
5.**Lead Time vs. Reliability**: Jerk provides the earliest signal but is also the most prone to false signals. Combine with lower derivatives for confirmation.
6.**Using isNew Incorrectly**: When processing live ticks within the same bar, use `Update(value, isNew: false)`. When a new bar opens, use `isNew: true` (default).
7.**Memory Footprint**: ~80 bytes per instance. Negligible for most use cases.
8.**Derivative Chain Verification**: JERK should equal the difference of consecutive ACCEL values. Use this identity to verify implementation correctness.
## References
- Newton, Isaac. (1687). "Philosophiæ Naturalis Principia Mathematica."