pub struct AdOscillator { /* private fields */ }Expand description
Williams A/D Oscillator — the volume-free Williams Accumulation/ Distribution line measured against its own moving average, so it oscillates around zero instead of drifting like the cumulative line.
The underlying line is Larry Williams’ volume-less A/D (1972), which uses a true high/low anchored on the prior close; the oscillator subtracts its 13-bar simple moving average:
TR_h_t = max(close_{t−1}, high_t)
TR_l_t = min(close_{t−1}, low_t)
WAD_t = WAD_{t−1} + (close_t − TR_l_t) if close_t > close_{t−1}
WAD_t = WAD_{t−1} + (close_t − TR_h_t) if close_t < close_{t−1}
WAD_t = WAD_{t−1} if close_t == close_{t−1}
WADOSC_t = WAD_t − SMA(WAD, 13)_tThis is distinct from the raw cumulative line, which Wickra ships as
Wad: Wad is the drifting line for divergence analysis,
while this oscillator is its zero-centred, mean-reverting form (positive
when accumulation is running ahead of its recent average, negative when
distribution is). The first bar only seeds the previous close; the first
oscillator value lands once the 13-bar average of the line is full.
§Example
use wickra_core::{Candle, Indicator, AdOscillator};
let mut indicator = AdOscillator::new();
let mut last = None;
for i in 0..80 {
let base = 100.0 + f64::from(i);
let candle =
Candle::new(base, base + 2.0, base - 2.0, base + 1.0, 10.0, i64::from(i)).unwrap();
last = indicator.update(candle);
}
assert!(last.is_some());Implementations§
Trait Implementations§
Source§impl Clone for AdOscillator
impl Clone for AdOscillator
Source§impl Debug for AdOscillator
impl Debug for AdOscillator
Source§impl Default for AdOscillator
impl Default for AdOscillator
Source§impl Indicator for AdOscillator
impl Indicator for AdOscillator
Source§type Input = Candle
type Input = Candle
f64 for a price, or Candle / Tick).Source§fn update(&mut self, candle: Candle) -> Option<f64>
fn update(&mut self, candle: Candle) -> Option<f64>
None if there is no value for this input. Read moreSource§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Source§fn is_ready(&self) -> bool
fn is_ready(&self) -> bool
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
Source§fn batch_nan_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
fn batch_nan_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
Source§fn batch_fast_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
fn batch_fast_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
batch_nan_into, but
an indicator with a vectorised kernel may reassociate its arithmetic to
run it in SIMD lanes. Each value then agrees with the exact batch to within
the tolerance the indicator documents (a few units in the last place), not
bit for bit; warmup positions, NaN placement and the output length are
identical. The kernels are deterministic: the same input produces the same
bits on every platform, with or without SIMD hardware. Read moreAuto Trait Implementations§
impl Freeze for AdOscillator
impl RefUnwindSafe for AdOscillator
impl Send for AdOscillator
impl Sync for AdOscillator
impl Unpin for AdOscillator
impl UnsafeUnpin for AdOscillator
impl UnwindSafe for AdOscillator
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>>
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
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> ⓘ
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> ⓘ
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