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:
DataChange::ReplaceandDataChange::Prepend: recompute everything (out.start()is 0);DataChange::Append: the lastcountslots are new (out.start() == len − count);DataChange::UpdateLast: the last slot changed (out.start() == len − 1).
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§
Sourcefn outputs(&self) -> &[OutputSpec]
fn outputs(&self) -> &[OutputSpec]
The outputs, in the order of out.column(o).
Sourcefn default_placement(&self) -> Placement
fn default_placement(&self) -> Placement
Where the outputs go by default.
Sourcefn update(
&mut self,
input: &IndicatorInput<'_>,
change: DataChange,
out: &mut IndicatorOutputs,
)
fn update( &mut self, input: &IndicatorInput<'_>, change: DataChange, out: &mut IndicatorOutputs, )
Updates the outputs for change; see the trait docs.
Provided Methods§
Sourcefn needs_volume(&self) -> bool
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".