Skip to main content

rolling_atr_mean

Function rolling_atr_mean 

Source
pub fn rolling_atr_mean(
    window: &mut VecDeque<Decimal>,
    new_tr: Decimal,
    period: usize,
) -> Decimal
Expand description

Compute the simple mean of true-range values in a sliding window.

Pure math used by rolling ATR adapters: push new_tr into the window, evict the oldest if the window exceeds period, then return the mean.

Returns Decimal::ZERO only when the window is empty (should not happen in normal use).