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

pub struct BollingerBands { /* fields omitted */ }
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 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

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.