pub struct Wad { /* private fields */ }Expand description
Williams Accumulation/Distribution — a cumulative price-only line that adds the day’s accumulation on up-closes and subtracts the day’s distribution on down-closes.
if close > prev_close: AD = close − min(low, prev_close) (true low)
if close < prev_close: AD = close − max(high, prev_close) (true high)
if close = prev_close: AD = 0
WAD_t = WAD_{t−1} + ADLarry Williams’ A/D line (distinct from Chaikin’s volume-based
Adl) uses no volume at all — it measures accumulation as
how far price closed above the true low on up-days and distribution as how
far it closed below the true high on down-days, then accumulates the result.
A rising WAD that diverges from a flat or falling price is the classic
accumulation signal; a falling WAD under a rising price warns of distribution.
The line is unbounded and its absolute level is meaningless — only its slope
and divergences against price matter. The first candle has no previous close,
so it seeds the reference and emits nothing; thereafter every bar emits the
running total. Each update is O(1).
§Example
use wickra_core::{Candle, Indicator, Wad};
let mut indicator = Wad::new();
let mut last = None;
for i in 0..20 {
let base = 100.0 + f64::from(i);
let c = Candle::new(base, base + 1.0, base - 1.0, base + 0.5, 1_000.0, 0).unwrap();
last = indicator.update(c);
}
assert!(last.is_some());Implementations§
Trait Implementations§
Source§impl Indicator for Wad
impl Indicator for Wad
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 Wad
impl RefUnwindSafe for Wad
impl Send for Wad
impl Sync for Wad
impl Unpin for Wad
impl UnsafeUnpin for Wad
impl UnwindSafe for Wad
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