Skip to main content

Indicator

Trait Indicator 

Source
pub trait Indicator: Send + Sync {
    type Output: Clone + Debug;

    // Required methods
    fn next(&mut self, candle: &Candle) -> Option<Self::Output>;
    fn reset(&mut self);
    fn warmup_period(&self) -> usize;
    fn clone_boxed(&self) -> Box<dyn Indicator<Output = Self::Output>>;

    // Provided method
    fn calculate(&self, candles: &[Candle]) -> Vec<Option<Self::Output>> { ... }
}
Expand description

Core interface for all streaming technical indicators.

Implementations should be stateful and cheap to next(). The default calculate helper performs a streaming pass over a slice of candles.

Required Associated Types§

Source

type Output: Clone + Debug

Concrete output type for this indicator (e.g., f64 or a struct).

Required Methods§

Source

fn next(&mut self, candle: &Candle) -> Option<Self::Output>

Feed one candle; returns Some(output) once warmup is satisfied, otherwise None.

Source

fn reset(&mut self)

Reset to initial state.

Source

fn warmup_period(&self) -> usize

Number of candles required before the first valid output.

Source

fn clone_boxed(&self) -> Box<dyn Indicator<Output = Self::Output>>

Clone into a boxed trait object.

Provided Methods§

Source

fn calculate(&self, candles: &[Candle]) -> Vec<Option<Self::Output>>

Batch compute over a candle series (default streaming loop).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Indicator for ADX

Source§

impl Indicator for ATR

Source§

impl Indicator for AccumDist

Source§

impl Indicator for BollingerBands

Source§

impl Indicator for CCI

Source§

impl Indicator for DEMA

Source§

impl Indicator for DonchianChannels

Source§

impl Indicator for EMA

Source§

impl Indicator for Ichimoku

Source§

impl Indicator for KeltnerChannels

Source§

impl Indicator for MACD

Source§

impl Indicator for MFI

Source§

impl Indicator for OBV

Source§

impl Indicator for ParabolicSar

Source§

impl Indicator for PivotPoints

Source§

impl Indicator for ROC

Source§

impl Indicator for RSI

Source§

impl Indicator for SMA

Source§

impl Indicator for StdDev

Source§

impl Indicator for Stochastic

Source§

impl Indicator for TEMA

Source§

impl Indicator for VWAP

Source§

impl Indicator for VolumeSMA

Source§

impl Indicator for WMA

Source§

impl Indicator for WilliamsR