Skip to main content

Module functions

Module functions 

Source
Expand description

Standalone batch indicator functions and incremental structs.

Ported from the original indicators crate lib. These work on slices (batch mode) or as incremental O(1)-per-tick structs.

§Incremental warm-up contract

Every Incremental* struct has the same update shape: it returns Option<T>, where None means “no value is defined yet”. Structs whose maths seeds from the first tick (EMA, ATR, MACD) return Some from the first call; the others return None until their warm-up completes:

Structupdate returnsFirst Some
IncrementalEmaOption<f64>first tick (seeds from it)
IncrementalAtrOption<f64>first tick (TR = high − low)
IncrementalRsiOption<f64>second tick (needs a prior price)
IncrementalMacdOption<(f64, f64, f64)>first tick (all EMAs seed from it)
IncrementalBollingerOption<BollingerBandsValue>after period ticks
EMA / ATR() — read via value() / is_ready()after period ticks (SMA seed)

Early EMA/MACD values are mathematically defined but still converging toward the batch equivalents (which warm up with an SMA seed or leading NaN); gate on your own bar count if you need fully-converged values.

None of these structs validate their inputs: feeding NaN poisons the internal state (NaN propagates through every subsequent value) without panicking. Filter non-finite ticks upstream.

Structs§

ATR
Incremental Wilder ATR.
BollingerBandsValue
Per-tick Bollinger Bands output (see IncrementalBollinger).
EMA
Incremental EMA — O(1) update, SMA warm-up.
IncrementalAtr
Incremental ATR — O(1) per-tick true-range EMA.
IncrementalBollinger
Incremental Bollinger Bands — per-tick bands over a rolling window.
IncrementalEma
Incremental EMA — O(1) update per tick that returns the new value each call.
IncrementalMacd
Incremental MACD — O(1) per-tick MACD line, signal, and histogram.
IncrementalRsi
Incremental RSI — O(1) per-tick, EMA-smoothed gains/losses.
IndicatorCalculator
Multi-period indicator calculator (batch mode).
StrategyIndicators
Bundle of per-strategy indicator series.

Functions§

atr
Average True Range (EMA-smoothed).
ema
Exponential Moving Average over a price slice. Returns a Vec of the same length; leading values are NaN until warm-up.
ema_nan_aware
EMA that handles leading NaN values, matching Python’s ewm(adjust=False) behaviour.
macd
MACD — returns (macd_line, signal_line, histogram).
rsi
Relative Strength Index.
sma
Simple Moving Average over a price slice.
true_range
True Range = max(H-L, |H-prevC|, |L-prevC|).