ParabolicSAR

Incremental, causal technical analysis documentation

Summary

ParabolicSAR is RTTA's streaming implementation of: Parabolic stop-and-reverse trailing trend indicator.

Update API

result = rtta.ParabolicSAR().update(high, low)

The update(...) call consumes one observation using high, low. advance(...) uses the same inputs when the caller wants to update state without materializing a Python return value.

Theory Of Operation

ParabolicSAR implements the streaming form of Parabolic stop-and-reverse trailing trend indicator. Each update(...) call consumes exactly one new observation tuple and advances the internal state before returning the current value or result struct.

Recurrence

Let \(z_t = (high_t, low_t)\) denote the observation consumed by one update(...) call and let \(\theta\) denote constructor parameters such as window lengths, thresholds, and smoothing constants.

\[SAR_t=SAR_{t-1}+AF_{t-1}(EP_{t-1}-SAR_{t-1})\]
\[EP_t=\begin{cases}\max(EP_{t-1},high_t),&trend_t=1\\\min(EP_{t-1},low_t),&trend_t=-1\end{cases}\]

The current high or low is tested against the unconstrained candidate first. When price crosses it, the trend reverses, \(SAR_t\) is reset to the prior extreme point (bounded by the adjacent highs or lows), and the acceleration factor restarts. Only a non-reversing candidate is clamped so that it does not penetrate the current or previous bar. This ordering is essential: clamping a rising candidate to the current low, or a falling candidate to the current high, before the crossing test would make reversal impossible.

The return value is the current scalar indicator value.

Implementation Notes

The recurrence is implemented in src/rtta/indicator.cpp in class ParabolicSAR. After a reversal, the next candidate is prepared from the new extreme and reset acceleration factor, preserving the canonical post-reversal sequence.

Reference