[][src]Struct ta::indicators::BollingerBands

pub struct BollingerBands { /* fields omitted */ }

A Bollinger Bands (BB). (BB). It is a type of infinite impulse response filter that calculates Bollinger Bands using Exponential Moving Average. The Bollinger Badns are represented by Average EMA and standard deviaton that is moved 'k' times away in both directions from calculated average value.

Formula

See EMA documentation.

SD formula

Where:

  • SDs - is value of standard deviation for N given probes.
  • SDٍx - is the mean value of observation.
  • SDN - is number of probes in observation.
  • SDxi - is i-th observed value from N elements observation.

and then BB is composed as:

  • BBMiddle Band - Exponential Moving Average (EMA).
  • BBUpper Band = N * (EMA + SD of observation * multipler (usually 2.0))
  • BBLower Band = N * (EMA - SD of observation * multipler (usually 2.0))

Example

 use ta::indicators::{BollingerBands, BollingerBandsOutput};
 use ta::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

Bollinger Bands, Wikipedia

Methods

impl BollingerBands[src]

pub fn new(length: u32, multiplier: f64) -> Result<Self>[src]

pub fn length(&self) -> u32[src]

pub fn multiplier(&self) -> f64[src]

Trait Implementations

impl Reset for BollingerBands[src]

impl Next<f64> for BollingerBands[src]

type Output = BollingerBandsOutput

impl<'a, T: Close> Next<&'a T> for BollingerBands[src]

type Output = BollingerBandsOutput

impl Clone for BollingerBands[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for BollingerBands[src]

impl Display for BollingerBands[src]

impl Debug for BollingerBands[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]