pub struct HammerPattern { /* private fields */ }Expand description
Hammer Pattern — detects bullish hammer and bearish hanging man candlestick patterns.
A hammer (bullish reversal, output +1) has:
- Small body in the upper portion of the range
- Lower shadow ≥ 2× the body size
- Little or no upper shadow (upper shadow ≤ 30% of total range)
A hanging man (bearish reversal, output -1) has the same shape but
occurs in an uptrend context. Since this indicator is stateless (no trend
context), it outputs +1 for any hammer-shaped bar and -1 if inverted
(small body in lower portion, long upper shadow).
Outputs 0 if no pattern is detected.
Always ready from the first bar.
§Example
use fin_primitives::signals::indicators::HammerPattern;
use fin_primitives::signals::Signal;
let hp = HammerPattern::new("hp").unwrap();
assert_eq!(hp.period(), 1);Implementations§
Trait Implementations§
Source§impl Signal for HammerPattern
impl Signal for HammerPattern
Source§fn period(&self) -> usize
fn period(&self) -> usize
Returns the number of bars required before the signal produces a value.
Source§fn is_ready(&self) -> bool
fn is_ready(&self) -> bool
Returns
true if the signal has accumulated enough bars to produce a value.Source§fn reset(&mut self)
fn reset(&mut self)
Resets the signal to its initial state as if no bars had been seen. Read more
Source§fn update_bar(&mut self, bar: &OhlcvBar) -> Result<SignalValue, FinError>
fn update_bar(&mut self, bar: &OhlcvBar) -> Result<SignalValue, FinError>
Auto Trait Implementations§
impl Freeze for HammerPattern
impl RefUnwindSafe for HammerPattern
impl Send for HammerPattern
impl Sync for HammerPattern
impl Unpin for HammerPattern
impl UnsafeUnpin for HammerPattern
impl UnwindSafe for HammerPattern
Blanket Implementations§
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
Mutably borrows from an owned value. Read more