pub struct BeltHold { /* private fields */ }Expand description
Belt-hold — a single-bar reversal: a long candle that opens at one extreme of its range (an “opening marubozu”) and runs the other way.
range = high − low
bullish (+1.0): green, opens at the low (open − low <= tol * range) & long body
bearish (−1.0): red, opens at the high (high − open <= tol * range) & long body
long body = |close − open| >= 0.5 * rangeOutput is 0.0 when the opening side carries a shadow, the body is short, or
the range is degenerate. shadow_tolerance defaults to 0.05 (5 % of the bar
range allowed on the opening side) 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 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 occupy a single dimension.
§Example
use wickra_core::{BeltHold, Candle, Indicator};
let mut indicator = BeltHold::new();
// Bullish belt-hold: opens at the low, closes near the high.
let candle = Candle::new(10.0, 12.0, 10.0, 11.5, 1.0, 0).unwrap();
assert_eq!(indicator.update(candle), Some(1.0));Implementations§
Source§impl BeltHold
impl BeltHold
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Construct a Belt-hold detector with the default 5 % opening-shadow tolerance.
Sourcepub fn with_tolerance(shadow_tolerance: f64) -> Result<Self>
pub fn with_tolerance(shadow_tolerance: f64) -> Result<Self>
Construct a Belt-hold detector with a custom opening-shadow tolerance.
shadow_tolerance must lie in [0, 1).
Sourcepub fn shadow_tolerance(&self) -> f64
pub fn shadow_tolerance(&self) -> f64
Configured opening-shadow tolerance.
Trait Implementations§
Source§impl Indicator for BeltHold
impl Indicator for BeltHold
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 BeltHold
impl RefUnwindSafe for BeltHold
impl Send for BeltHold
impl Sync for BeltHold
impl Unpin for BeltHold
impl UnsafeUnpin for BeltHold
impl UnwindSafe for BeltHold
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