pub struct BollingerBands { /* private fields */ }
Expand description
A Bollinger Bands (BB). (BB). It is a type of infinite impulse response filter that calculates Bollinger Bands using Exponential Moving Average. The Bollinger Bands are represented by Average EMA and standard deviaton that is moved ‘k’ times away in both directions from calculated average value.
§Formula
See SMA, SD documentation.
BB is composed as:
- BBMiddle Band - Simple Moving Average (SMA).
- BBUpper Band = SMA + SD of observation * multipler (usually 2.0)
- BBLower Band = SMA - SD of observation * multipler (usually 2.0)
§Example
use quantaxis_rs::indicators::{BollingerBands, BollingerBandsOutput};
use quantaxis_rs::Next;
let mut bb = BollingerBands::new(3, 2.0_f64).unwrap();
let out_0 = bb.next(2.0);
let out_1 = bb.next(5.0);
assert_eq!(out_0.average, 2.0);
assert_eq!(out_0.upper, 2.0);
assert_eq!(out_0.lower, 2.0);
assert_eq!(out_1.average, 3.5);
assert_eq!(out_1.upper, 6.5);
assert_eq!(out_1.lower, 0.5);
§Links
Implementations§
Trait Implementations§
Source§impl Clone for BollingerBands
impl Clone for BollingerBands
Source§fn clone(&self) -> BollingerBands
fn clone(&self) -> BollingerBands
Returns a duplicate 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 BollingerBands
impl Debug for BollingerBands
Source§impl Default for BollingerBands
impl Default for BollingerBands
Source§impl Display for BollingerBands
impl Display for BollingerBands
Source§impl Next<f64> for BollingerBands
impl Next<f64> for BollingerBands
Auto Trait Implementations§
impl Freeze for BollingerBands
impl RefUnwindSafe for BollingerBands
impl Send for BollingerBands
impl Sync for BollingerBands
impl Unpin for BollingerBands
impl UnwindSafe for BollingerBands
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