pub struct MatHold { /* private fields */ }Expand description
Mat Hold — a 5-bar bullish continuation. A long white candle is followed by a brief three-bar pullback that gaps up and then drifts on small bodies without surrendering much ground, after which a white candle breaks to a new high and the uptrend resumes.
long body = |close − open| >= 0.5 * (high − low)
bar1 white & long
bar2 small body gapping up above bar1 (min(o2,c2) > close1)
bar2, bar3, bar4 each small (|body| <= 0.5 · body1)
the pullback holds (min low of bars 2..4 > close1 − penetration·body1)
bar5 white, closing at a new high (close5 > max high of bars 1..4)Output is +1.0 when the pattern completes and 0.0 otherwise. Mat Hold is a
single-direction (bullish-only) continuation, so it never emits −1.0. The
first four bars always return 0.0 because the five-bar window is not yet
filled. penetration is how far the pullback may retrace into the first body;
it defaults to 0.5 (TA-Lib’s CDLMATHOLD default) and must lie in [0, 1).
Body 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 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, MatHold};
let mut indicator = MatHold::new();
indicator.update(Candle::new(10.0, 15.1, 9.9, 15.0, 1.0, 0).unwrap());
indicator.update(Candle::new(16.0, 16.1, 15.4, 15.5, 1.0, 1).unwrap());
indicator.update(Candle::new(15.5, 15.6, 14.9, 15.0, 1.0, 2).unwrap());
indicator.update(Candle::new(15.0, 15.1, 14.4, 14.5, 1.0, 3).unwrap());
let out = indicator
.update(Candle::new(14.5, 17.1, 14.4, 17.0, 1.0, 4).unwrap());
assert_eq!(out, Some(1.0));Implementations§
Source§impl MatHold
impl MatHold
Sourcepub fn with_penetration(penetration: f64) -> Result<Self>
pub fn with_penetration(penetration: f64) -> Result<Self>
Construct a Mat Hold detector with a custom penetration fraction.
penetration must lie in [0, 1).
Sourcepub fn penetration(&self) -> f64
pub fn penetration(&self) -> f64
Configured penetration fraction.
Trait Implementations§
Source§impl Indicator for MatHold
impl Indicator for MatHold
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 MatHold
impl RefUnwindSafe for MatHold
impl Send for MatHold
impl Sync for MatHold
impl Unpin for MatHold
impl UnsafeUnpin for MatHold
impl UnwindSafe for MatHold
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