pub struct MacdHistogram { /* private fields */ }Expand description
MACD Histogram — the macd − signal bar of MacdIndicator as a
standalone scalar indicator.
macd = EMA(fast) − EMA(slow)
signal = EMA(macd, signal)
histogram = macd − signalThe histogram is the most actively traded part of MACD: it crosses zero
exactly when the MACD line crosses its signal, and its slope measures
whether that momentum is accelerating or fading. This wrapper exposes just
that series for pipelines that want a plain f64 stream rather than the
full MacdOutput; for the line and signal alongside
it, use MacdIndicator directly.
Standard parameters are fast = 12, slow = 26, signal = 9, so the
first value lands after slow + signal − 1 inputs — exactly when
MacdIndicator emits its first full output.
§Example
use wickra_core::{Indicator, MacdHistogram};
let mut indicator = MacdHistogram::new(12, 26, 9).unwrap();
let mut last = None;
for i in 0..80 {
last = indicator.update(100.0 + f64::from(i));
}
assert!(last.is_some());Implementations§
Source§impl MacdHistogram
impl MacdHistogram
Sourcepub fn new(fast: usize, slow: usize, signal: usize) -> Result<Self>
pub fn new(fast: usize, slow: usize, signal: usize) -> Result<Self>
Construct a MACD histogram with the given periods.
§Errors
Returns [Error::PeriodZero] if any period is zero, and
[Error::InvalidPeriod] if fast >= slow.
Trait Implementations§
Source§impl Clone for MacdHistogram
impl Clone for MacdHistogram
Source§fn clone(&self) -> MacdHistogram
fn clone(&self) -> MacdHistogram
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MacdHistogram
impl Debug for MacdHistogram
Source§impl Indicator for MacdHistogram
impl Indicator for MacdHistogram
Source§fn update(&mut self, input: f64) -> Option<f64>
fn update(&mut self, input: f64) -> Option<f64>
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto Trait Implementations§
impl Freeze for MacdHistogram
impl RefUnwindSafe for MacdHistogram
impl Send for MacdHistogram
impl Sync for MacdHistogram
impl Unpin for MacdHistogram
impl UnsafeUnpin for MacdHistogram
impl UnwindSafe for MacdHistogram
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
None during warmup) per input.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more