pub struct EmaEngine { /* private fields */ }Expand description
Exponential Moving Average (EMA) over the closing price.
Wraps the shared Ema smoother rather than repeating its recurrence, so both surfaces stay
one calculation. The first output appears with the period-th bar in either initialisation:
with EmaInit::FirstSample the average is already running before that and its early values
are withheld, with EmaInit::Sma it is not defined before that at all.
Indicator::reset clears the average and the bar counter, so the next series starts
deterministically.
Implementations§
Source§impl EmaEngine
impl EmaEngine
pub fn new(period: usize) -> Self
Sourcepub fn with_init(self, init: EmaInit) -> Self
pub fn with_init(self, init: EmaInit) -> Self
Selects the initialisation; see EmaInit. Additive to EmaEngine::new, which keeps
the first-sample seed. Indicators that nest EMAs internally (DEMA, TEMA, MACD, …) are
deliberately not affected.
pub fn init(&self) -> EmaInit
Trait Implementations§
Source§impl Indicator for EmaEngine
impl Indicator for EmaEngine
fn name(&self) -> &str
fn warmup_period(&self) -> usize
fn reset(&mut self)
fn on_bar(&mut self, bar: &Bar) -> Option<IndicatorOutput>
fn alerts(&self) -> Vec<IndicatorAlert>
Source§fn on_checked_bar(
&mut self,
bar: &Bar,
) -> Result<Option<IndicatorOutput>, BarValidationError>
fn on_checked_bar( &mut self, bar: &Bar, ) -> Result<Option<IndicatorOutput>, BarValidationError>
Validates a bar before forwarding it to
Indicator::on_bar.Auto Trait Implementations§
impl Freeze for EmaEngine
impl RefUnwindSafe for EmaEngine
impl Send for EmaEngine
impl Sync for EmaEngine
impl Unpin for EmaEngine
impl UnsafeUnpin for EmaEngine
impl UnwindSafe for EmaEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more