pub struct DoubleBollinger { /* private fields */ }Expand description
Double Bollinger Bands: two concentric Bollinger envelopes (Kathy Lien).
middle = SMA(period)
sigma = population stddev over the window
upper_outer = middle + k_outer · sigma // wide channel (often 2σ)
upper_inner = middle + k_inner · sigma // narrow channel (often 1σ)
lower_inner = middle − k_inner · sigma
lower_outer = middle − k_outer · sigmaLien’s trading framework partitions price into three zones:
- Sell zone: close below
lower_inner. - Neutral zone: close between
lower_innerandupper_inner. - Buy zone: close above
upper_inner.
A close beyond the outer band marks an extended move that traders typically
fade or trail. The constructor enforces k_outer > k_inner so the outputs
remain monotonically ordered.
§Example
use wickra_core::{DoubleBollinger, Indicator};
let mut indicator = DoubleBollinger::new(20, 1.0, 2.0).unwrap();
let mut last = None;
for i in 0..40 {
last = indicator.update(100.0 + (f64::from(i) * 0.3).sin() * 6.0);
}
assert!(last.is_some());Implementations§
Source§impl DoubleBollinger
impl DoubleBollinger
Sourcepub fn new(period: usize, k_inner: f64, k_outer: f64) -> Result<Self>
pub fn new(period: usize, k_inner: f64, k_outer: f64) -> Result<Self>
Construct a new Double Bollinger Bands indicator.
§Errors
Returns Error::PeriodZero if period == 0,
Error::NonPositiveMultiplier if either k_inner or k_outer is
non-positive or non-finite, and Error::InvalidPeriod if
k_outer <= k_inner (the outer band must strictly enclose the inner
band so the zone-partitioning interpretation holds).
Sourcepub const fn parameters(&self) -> (usize, f64, f64)
pub const fn parameters(&self) -> (usize, f64, f64)
Configured (period, k_inner, k_outer).
Trait Implementations§
Source§impl Clone for DoubleBollinger
impl Clone for DoubleBollinger
Source§fn clone(&self) -> DoubleBollinger
fn clone(&self) -> DoubleBollinger
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 DoubleBollinger
impl Debug for DoubleBollinger
Source§impl Indicator for DoubleBollinger
impl Indicator for DoubleBollinger
Source§type Output = DoubleBollingerOutput
type Output = DoubleBollingerOutput
Type of one output value.
Source§fn update(&mut self, value: f64) -> Option<DoubleBollingerOutput>
fn update(&mut self, value: f64) -> Option<DoubleBollingerOutput>
Feed one new data point into the indicator and return the freshly computed
output, or
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Reset all internal state, leaving the indicator equivalent to a freshly
constructed instance with the same parameters.
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
Number of inputs required before the first non-
None output can be produced.Auto Trait Implementations§
impl Freeze for DoubleBollinger
impl RefUnwindSafe for DoubleBollinger
impl Send for DoubleBollinger
impl Sync for DoubleBollinger
impl Unpin for DoubleBollinger
impl UnsafeUnpin for DoubleBollinger
impl UnwindSafe for DoubleBollinger
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
Run the indicator over a slice of inputs in order, returning one output (or
None during warmup) per input.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more