pub struct OnNeck { /* private fields */ }Expand description
On-Neck — a 2-bar bearish continuation. In a decline a long black candle is followed by a white candle that opens below the black bar’s low yet rallies only as far as the black bar’s low (the “neckline”). The feeble bounce shows sellers remain in control.
long body = |close − open| >= 0.5 * (high − low)
bar1 black & long
bar2 white, opens below bar1's low (open2 < low1)
bar2 closes at bar1's low (the neckline) (|close2 − low1| <= 0.05 · range1)Output is −1.0 when the pattern completes and 0.0 otherwise. On-Neck is a
single-direction (bearish-only) continuation, so it never emits +1.0. The
first bar always returns 0.0 because the two-bar window is not yet filled.
Body and neckline thresholds follow the geometric house style rather than
TA-Lib’s rolling averages. 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, OnNeck};
let mut indicator = OnNeck::new();
indicator.update(Candle::new(15.0, 15.1, 9.0, 10.0, 1.0, 0).unwrap());
let out = indicator
.update(Candle::new(7.0, 9.1, 6.9, 9.0, 1.0, 1).unwrap());
assert_eq!(out, Some(-1.0));Implementations§
Trait Implementations§
Source§impl Indicator for OnNeck
impl Indicator for OnNeck
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 OnNeck
impl RefUnwindSafe for OnNeck
impl Send for OnNeck
impl Sync for OnNeck
impl Unpin for OnNeck
impl UnsafeUnpin for OnNeck
impl UnwindSafe for OnNeck
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