pub struct Macd { /* private fields */ }Expand description
MACD indicator.
Measures the relationship between two EMAs. Produces three outputs:
- MACD line: fast EMA - slow EMA
- Signal line: EMA of MACD line
- Histogram: MACD - Signal
This implementation returns the MACD line. Use MacdSignal for signal line
or MacdHistogram for histogram.
§Standard Parameters
- Fast: 12
- Slow: 26
- Signal: 9
§Example
use quant_indicators::{Indicator, Macd};
use quant_primitives::Candle;
use chrono::Utc;
use rust_decimal_macros::dec;
let ts = Utc::now();
let candles: Vec<Candle> = (0..30).map(|i| {
Candle::new(dec!(100), dec!(110), dec!(90), dec!(100) + rust_decimal::Decimal::from(i), dec!(1000), ts).unwrap()
}).collect();
let macd = Macd::new(12, 26).unwrap();
let series = macd.compute(&candles).unwrap();Implementations§
Trait Implementations§
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> 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