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
Auto Trait Implementations
impl RefUnwindSafe for BollingerBands
impl Send for BollingerBands
impl Sync for BollingerBands
impl Unpin for BollingerBands
impl UnwindSafe for BollingerBands
Blanket Implementations
Mutably borrows from an owned value. Read more