VolumeRunBarGenerator

Incremental, causal technical analysis documentation

Summary

VolumeRunBarGenerator implements a constant-threshold volume run bar. Buy and sell volume accumulate separately across the entire active bar, and the bar closes when either side's total reaches threshold.

Update API

ind = rtta.VolumeRunBarGenerator(threshold=10000.0)
result = ind.update(close, volume)
# result.bar_open, bar_close, bar_high, bar_low, bar_volume,
# result.direction, result.complete, result.bars

Theory Of Operation

Volume run bars measure persistent one-sided volume, not uninterrupted same-sign streaks. Opposite-side volume remains in its own tally and does not reset the bar or its OHLC. RTTA uses a fixed threshold on the canonical dominant-side statistic; adaptive expected-run thresholds can be maintained by the caller when desired.

Recurrence

Classify each price by the tick rule; a flat price inherits the most recent nonzero sign. With \(v_t^+=\max(v_t,0)\), maintain

\[V_t^+=\sum v_i^+1_{\{b_i=+1\}},\qquad V_t^-=\sum v_i^+1_{\{b_i=-1\}},\]
\[\theta_t=\max(V_t^+,V_t^-).\]

When \(\theta_t\ge\texttt{threshold}\), the bar completes. bar_volume is \(\theta_t\), and direction identifies the side with the larger total. Incomplete results report the current \(\theta_t\) with direction zero. OHLC spans all ticks in the bar, including alternating signs.

After completion the side totals and OHLC reset. The previous price and last nonzero tick sign remain available to classify the first tick of the next bar. The first observation of the stream seeds price and therefore contributes no signed volume.

Implementation Notes

The recurrence is implemented in src/rtta/indicator.cpp in class VolumeRunBarGenerator. Result type is InformationBarResult.

Reference