pub struct SimpleMovingAverage { /* private fields */ }
Expand description
Simple moving average (SMA).
§Formula
Where:
- SMAt - value of simple moving average at a point of time t
- n - number of periods (length)
- pt - input value at a point of time t
§Parameters
- n - number of periods (integer greater than 0)
§Example
use ta::indicators::SimpleMovingAverage;
use ta::{Calculate, Next};
let mut sma = SimpleMovingAverage::new(3).unwrap();
assert_eq!(sma.calc(10.0), 10.0);
assert_eq!(sma.calc(11.0), 10.5);
assert_eq!(sma.calc(12.0), 11.0);
assert_eq!(sma.calc(13.0), 12.0);
§Links
Implementations§
Trait Implementations§
Source§impl Clone for SimpleMovingAverage
impl Clone for SimpleMovingAverage
Source§fn clone(&self) -> SimpleMovingAverage
fn clone(&self) -> SimpleMovingAverage
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SimpleMovingAverage
impl Debug for SimpleMovingAverage
Source§impl Default for SimpleMovingAverage
impl Default for SimpleMovingAverage
Source§impl Display for SimpleMovingAverage
impl Display for SimpleMovingAverage
Auto Trait Implementations§
impl Freeze for SimpleMovingAverage
impl RefUnwindSafe for SimpleMovingAverage
impl Send for SimpleMovingAverage
impl Sync for SimpleMovingAverage
impl Unpin for SimpleMovingAverage
impl UnwindSafe for SimpleMovingAverage
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