pub struct DerivativeOscillator { /* private fields */ }Expand description
Derivative Oscillator — Constance Brown’s double-smoothed RSI histogram.
The RSI is smoothed twice with EMAs, then a simple moving average of that double-smoothed line is subtracted as a signal, leaving a zero-centered histogram:
rsi = RSI(price, rsi_period)
s1 = EMA(rsi, smooth1)
s2 = EMA(s1, smooth2) // double-smoothed RSI
signal = SMA(s2, signal_period)
DerivativeOscillator = s2 - signalThe double EMA smoothing strips the RSI’s high-frequency noise, and
subtracting the SMA signal removes the residual level, so the result
oscillates around zero: positive (and rising) bars mark accelerating bullish
momentum, negative bars bearish. Brown’s defaults are rsi_period = 14,
smooth1 = 5, smooth2 = 3, signal_period = 9.
The first value lands after rsi_period + smooth1 + smooth2 + signal_period − 2
inputs, the point at which the whole RSI → EMA → EMA → SMA chain is seeded.
§Example
use wickra_core::{DerivativeOscillator, Indicator};
let mut indicator = DerivativeOscillator::new(14, 5, 3, 9).unwrap();
let mut last = None;
for i in 0..120 {
last = indicator.update(100.0 + (f64::from(i) * 0.2).sin() * 5.0);
}
assert!(last.is_some());Implementations§
Trait Implementations§
Source§impl Clone for DerivativeOscillator
impl Clone for DerivativeOscillator
Source§fn clone(&self) -> DerivativeOscillator
fn clone(&self) -> DerivativeOscillator
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 DerivativeOscillator
impl Debug for DerivativeOscillator
Source§impl Indicator for DerivativeOscillator
impl Indicator for DerivativeOscillator
Source§fn update(&mut self, input: f64) -> Option<f64>
fn update(&mut self, input: f64) -> Option<f64>
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 DerivativeOscillator
impl RefUnwindSafe for DerivativeOscillator
impl Send for DerivativeOscillator
impl Sync for DerivativeOscillator
impl Unpin for DerivativeOscillator
impl UnsafeUnpin for DerivativeOscillator
impl UnwindSafe for DerivativeOscillator
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> BatchNanExt for T
impl<T> BatchNanExt for T
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