pub struct Tweezer { /* private fields */ }Expand description
Tweezer — a 2-bar reversal pattern where two consecutive candles share an extreme.
tol = tolerance * |prev.high| + tolerance * |prev.low| (per leg)
tweezer_top = |curr.high − prev.high| <= tol_high
tweezer_bot = |curr.low − prev.low| <= tol_lowThe output is −1.0 for a Tweezer Top (matched highs), +1.0 for a
Tweezer Bottom (matched lows), and 0.0 otherwise. If both extremes
match — a flat pair of candles — the bottom wins by convention (bullish
rejection of the low). tolerance defaults to 0.001 (10 bps relative)
and must lie in [0, 1).
Pattern-shape check only — no trend filter is applied; combine with a trend indicator for actionable signals.
§Signed ±1 encoding
This detector already emits the uniform candlestick sign convention shared
across the pattern family — +1.0 bullish, −1.0 bearish, 0.0 no
pattern — so it drops straight into a machine-learning feature matrix where
the bullish and bearish variants of the pattern occupy a single dimension.
§Example
use wickra_core::{Candle, Indicator, Tweezer};
let mut indicator = Tweezer::new();
indicator.update(Candle::new(11.0, 12.0, 9.5, 9.6, 1.0, 0).unwrap());
// Matching low.
let out = indicator.update(Candle::new(9.7, 10.5, 9.5, 10.2, 1.0, 1).unwrap());
assert_eq!(out, Some(1.0));Implementations§
Trait Implementations§
Source§impl Indicator for Tweezer
impl Indicator for Tweezer
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 Tweezer
impl RefUnwindSafe for Tweezer
impl Send for Tweezer
impl Sync for Tweezer
impl Unpin for Tweezer
impl UnsafeUnpin for Tweezer
impl UnwindSafe for Tweezer
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