Skip to main content

Macd

Struct Macd 

Source
pub struct Macd { /* private fields */ }
Expand description

Moving Average Convergence Divergence.

MACD = Ema(fast_len)(close) - Ema(slow_len)(close), both the shared Ema with its first-sample seed, running from the first bar; the line is published from the slow_len-th bar on. extra["signal"] is an Ema(signal_len) over the published MACD values, seeded with the first of them, and extra["hist"] is MACD - signal. Alerts fire on signal and zero crosses.

First output: with the slow_len-th bar. Indicator::reset clears all three averages.

Implementations§

Source§

impl Macd

Source

pub fn new(fast_len: usize, slow_len: usize, signal_len: usize) -> Self

Source

pub fn with_defaults() -> Self

Trait Implementations§

Source§

impl Indicator for Macd

Source§

fn name(&self) -> &str

Source§

fn warmup_period(&self) -> usize

Source§

fn on_bar(&mut self, bar: &Bar) -> Option<IndicatorOutput>

Source§

fn reset(&mut self)

Source§

fn alerts(&self) -> Vec<IndicatorAlert>

Source§

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 Macd

§

impl RefUnwindSafe for Macd

§

impl Send for Macd

§

impl Sync for Macd

§

impl Unpin for Macd

§

impl UnsafeUnpin for Macd

§

impl UnwindSafe for Macd

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.