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 the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto 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