Skip to main content

Indicator

Trait Indicator 

Source
pub trait Indicator: Send {
    // Required methods
    fn name(&self) -> &str;
    fn outputs(&self) -> &[OutputSpec];
    fn default_placement(&self) -> Placement;
    fn warmup(&self) -> usize;
    fn update(
        &mut self,
        input: &IndicatorInput<'_>,
        change: DataChange,
        out: &mut IndicatorOutputs,
    );

    // Provided method
    fn needs_volume(&self) -> bool { ... }
}
Expand description

A technical indicator, computed incrementally by the chart when its source series changes.

update gets the source and what changed:

Append and UpdateLast must be O(1) per slot and must not allocate (update_last is a hot path). Gap bars (input.bar(i) == None) should give NaN.

Required Methods§

Source

fn name(&self) -> &str

Display name, e.g. "SMA 20".

Source

fn outputs(&self) -> &[OutputSpec]

The outputs, in the order of out.column(o).

Source

fn default_placement(&self) -> Placement

Where the outputs go by default.

Source

fn warmup(&self) -> usize

Number of leading valid bars whose outputs are NaN.

Source

fn update( &mut self, input: &IndicatorInput<'_>, change: DataChange, out: &mut IndicatorOutputs, )

Updates the outputs for change; see the trait docs.

Provided Methods§

Source

fn needs_volume(&self) -> bool

Whether the indicator reads volume; add_indicator refuses sources without it.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§