pub struct TwoCrows { /* private fields */ }Expand description
Two Crows — a 3-bar bearish reversal pattern that appears after an advance.
bar1 green (long white)
bar2 red & its body gaps up above bar1's body (bar2.close > bar1.close)
bar3 red & opens inside bar2's body (bar2.close < bar3.open < bar2.open)
& closes inside bar1's body (bar1.open < bar3.close < bar1.close)Output is −1.0 when the pattern completes and 0.0 otherwise. Two Crows is
a single-direction (bearish-only) pattern, so it never emits +1.0. The
first two bars always return 0.0 because the three-bar window is not yet
filled. Pattern-shape check only — no trend filter is applied; combine with a
trend indicator for actionable signals.
§Signed ±1 encoding
This detector emits the uniform candlestick sign convention shared across the
pattern family — −1.0 bearish, 0.0 no pattern — so it drops straight into
a machine-learning feature matrix as a single dimension.
§Example
use wickra_core::{Candle, Indicator, TwoCrows};
let mut indicator = TwoCrows::new();
indicator.update(Candle::new(10.0, 12.2, 9.9, 12.0, 1.0, 0).unwrap());
indicator.update(Candle::new(14.0, 14.2, 12.9, 13.0, 1.0, 1).unwrap());
let out = indicator
.update(Candle::new(13.5, 13.6, 10.9, 11.0, 1.0, 2).unwrap());
assert_eq!(out, Some(-1.0));Implementations§
Trait Implementations§
Source§impl Indicator for TwoCrows
impl Indicator for TwoCrows
Source§type Input = Candle
type Input = Candle
Type of one input data point (typically
f64 for a price, or Candle / Tick).Source§fn update(&mut self, candle: Candle) -> Option<f64>
fn update(&mut self, candle: Candle) -> 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 TwoCrows
impl RefUnwindSafe for TwoCrows
impl Send for TwoCrows
impl Sync for TwoCrows
impl Unpin for TwoCrows
impl UnsafeUnpin for TwoCrows
impl UnwindSafe for TwoCrows
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