pub struct VolatilityRegimeDetector { /* private fields */ }Expand description
Volatility regime: Bollinger Bands against a Keltner Channel.
Bollinger Bands over period closes at bb_mult population standard deviations
(BollingerBands); a Keltner Channel with an EMA(period) basis and bands at kc_mult
times the plain mean of the last 10 true ranges (KeltnerChannelEngine(period, 10, kc_mult)). Then
- squeeze (
value = -1): both Bollinger bands inside the channel,bb_upper <= kc_upperandbb_lower >= kc_lower; - otherwise expansion (
value = 1):bb_width > 1.3 · kc_width; - otherwise normal (
value = 0).
Widths are upper - lower, the channel’s at least 1e-8; both are in extra (bb_width,
kc_width), with extra["squeeze"] as 1 or 0. The two middles differ (SMA against EMA), so on
a drifting series the bands can leave the channel on one side without the width test firing.
First output once both have one: with bar max(period, 10).
Implementations§
Source§impl VolatilityRegimeDetector
impl VolatilityRegimeDetector
pub fn new(period: usize, bb_mult: f64, kc_mult: f64) -> Self
pub fn with_defaults() -> Self
pub fn state(&self) -> VolatilityState
Trait Implementations§
Source§impl Clone for VolatilityRegimeDetector
impl Clone for VolatilityRegimeDetector
Source§fn clone(&self) -> VolatilityRegimeDetector
fn clone(&self) -> VolatilityRegimeDetector
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 VolatilityRegimeDetector
impl Debug for VolatilityRegimeDetector
Source§impl Indicator for VolatilityRegimeDetector
impl Indicator for VolatilityRegimeDetector
fn name(&self) -> &str
fn warmup_period(&self) -> usize
fn reset(&mut self)
fn on_bar(&mut self, bar: &Bar) -> Option<IndicatorOutput>
fn alerts(&self) -> Vec<IndicatorAlert>
Source§fn on_checked_bar(
&mut self,
bar: &Bar,
) -> Result<Option<IndicatorOutput>, BarValidationError>
fn on_checked_bar( &mut self, bar: &Bar, ) -> Result<Option<IndicatorOutput>, BarValidationError>
Validates a bar before forwarding it to
Indicator::on_bar.Auto Trait Implementations§
impl Freeze for VolatilityRegimeDetector
impl RefUnwindSafe for VolatilityRegimeDetector
impl Send for VolatilityRegimeDetector
impl Sync for VolatilityRegimeDetector
impl Unpin for VolatilityRegimeDetector
impl UnsafeUnpin for VolatilityRegimeDetector
impl UnwindSafe for VolatilityRegimeDetector
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