EfficiencyRatio

Incremental, causal technical analysis documentation

Summary

EfficiencyRatio is RTTA's streaming implementation of: Kaufman efficiency ratio of net directional move to path length over a rolling window.

Update API

result = rtta.EfficiencyRatio().update(close)

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

Theory Of Operation

EfficiencyRatio is the direction/noise ratio that drives Kama. Values near 1 mean a clean directional move; values near 0 mean a noisy path with little net displacement.

Recurrence

Let \(c_t = close_t\) and \(n\) the window.

\[ER_t = \frac{|c_t - c_{t-n}|}{\sum_{i=0}^{n-1} |c_{t-i} - c_{t-i-1}|}\]

The denominator is a rolling sum of absolute one-step changes. The numerator uses the close from \(n\) samples earlier, matching the efficiency term inside KAMA.

Exactly \(n\) price changes require \(n+1\) closes. With fillna=False, the first \(n\) updates therefore return NaN, and the first complete ratio is returned on update \(n+1\). With fillna=True, startup uses all changes seen so far; the first close returns 0. The ratio is bounded to \([0,1]\) by the triangle inequality (with safe division for a flat path).

The return value is the current scalar indicator value.

Composed Primitives

Kama

Implementation Notes

The recurrence is implemented in src/rtta/indicator.cpp in class EfficiencyRatio.

Reference