pub struct StickSandwich { /* private fields */ }Expand description
Stick Sandwich — a 3-bar bullish reversal. A black candle is followed by a white candle that trades entirely above the first close, then a second black candle drives price back down to close at the same level as the first. The matching closes “sandwich” the white candle and mark a support floor.
bar1 black, bar2 white, bar3 black
bar2 trades above bar1's close: low2 > close1
matching closes: |close3 − close1| <= 0.1 * (high1 − low1)Output is +1.0 when the pattern completes and 0.0 otherwise. Stick Sandwich
is a single-direction (bullish-only) reversal, so it never emits −1.0. The
first two bars always return 0.0 because the three-bar window is not yet
filled. The matching-close tolerance follows the geometric house style (a fixed
fraction of the first bar’s range) 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 bullish, 0.0 no pattern — so it drops straight into
a machine-learning feature matrix as a single dimension.
§Example
use wickra_core::{Candle, Indicator, StickSandwich};
let mut indicator = StickSandwich::new();
indicator.update(Candle::new(12.0, 12.1, 9.9, 10.0, 1.0, 0).unwrap());
indicator.update(Candle::new(10.5, 11.6, 10.4, 11.5, 1.0, 1).unwrap());
let out = indicator
.update(Candle::new(11.5, 11.6, 9.9, 10.0, 1.0, 2).unwrap());
assert_eq!(out, Some(1.0));Implementations§
Source§impl StickSandwich
impl StickSandwich
Trait Implementations§
Source§impl Clone for StickSandwich
impl Clone for StickSandwich
Source§fn clone(&self) -> StickSandwich
fn clone(&self) -> StickSandwich
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StickSandwich
impl Debug for StickSandwich
Source§impl Default for StickSandwich
impl Default for StickSandwich
Source§fn default() -> StickSandwich
fn default() -> StickSandwich
Source§impl Indicator for StickSandwich
impl Indicator for StickSandwich
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 StickSandwich
impl RefUnwindSafe for StickSandwich
impl Send for StickSandwich
impl Sync for StickSandwich
impl Unpin for StickSandwich
impl UnsafeUnpin for StickSandwich
impl UnwindSafe for StickSandwich
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