pub struct Ema { /* private fields */ }Expand description
Exponential Moving Average indicator.
Computes a weighted moving average that gives more weight to recent prices. The weighting decreases exponentially for older prices.
§Formula
multiplier = 2 / (period + 1) EMA_today = (Close - EMA_yesterday) * multiplier + EMA_yesterday
The first EMA value is the SMA of the first period candles.
§Example
use quant_indicators::{Indicator, Ema};
use quant_primitives::Candle;
use chrono::Utc;
use rust_decimal_macros::dec;
let ts = Utc::now();
let candles: Vec<Candle> = (0..20).map(|i| {
Candle::new(dec!(100), dec!(110), dec!(90), dec!(100) + rust_decimal::Decimal::from(i), dec!(1000), ts).unwrap()
}).collect();
let ema = Ema::new(20).unwrap();
let series = ema.compute(&candles).unwrap();Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ema
impl RefUnwindSafe for Ema
impl Send for Ema
impl Sync for Ema
impl Unpin for Ema
impl UnsafeUnpin for Ema
impl UnwindSafe for Ema
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