pub struct WilliamsFractals { /* private fields */ }Expand description
Williams Fractals — Bill Williams’ five-bar swing detector. A bar is an up fractal if its high is strictly above the highs of the two bars immediately before and the two bars immediately after. A bar is a down fractal if its low is strictly below the lows of those same four neighbours. Because confirmation requires two bars to the right of the candidate, the indicator inherently lags by two bars.
The first output lands at the fifth candle and corresponds to the third candle (the centre of the window). Subsequent outputs slide the window by one bar.
§Example
use wickra_core::{Candle, Indicator, WilliamsFractals};
let mut wf = WilliamsFractals::new();
// Build a V-shape with a clear high at index 2.
let highs = [1.0, 2.0, 5.0, 2.0, 1.0];
for (i, &h) in highs.iter().enumerate() {
let c = Candle::new(h, h, h - 0.5, h, 1.0, i as i64).unwrap();
let _ = wf.update(c);
}
// At candle 5 the third bar's high of 5.0 is confirmed as an up fractal.Implementations§
Trait Implementations§
Source§impl Clone for WilliamsFractals
impl Clone for WilliamsFractals
Source§fn clone(&self) -> WilliamsFractals
fn clone(&self) -> WilliamsFractals
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 WilliamsFractals
impl Debug for WilliamsFractals
Source§impl Default for WilliamsFractals
impl Default for WilliamsFractals
Source§impl Indicator for WilliamsFractals
impl Indicator for WilliamsFractals
Source§type Input = Candle
type Input = Candle
Type of one input data point (typically
f64 for a price, or Candle / Tick).Source§type Output = WilliamsFractalsOutput
type Output = WilliamsFractalsOutput
Type of one output value.
Source§fn update(&mut self, candle: Candle) -> Option<WilliamsFractalsOutput>
fn update(&mut self, candle: Candle) -> Option<WilliamsFractalsOutput>
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 WilliamsFractals
impl RefUnwindSafe for WilliamsFractals
impl Send for WilliamsFractals
impl Sync for WilliamsFractals
impl Unpin for WilliamsFractals
impl UnsafeUnpin for WilliamsFractals
impl UnwindSafe for WilliamsFractals
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> 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