pub struct EngulfingPattern { /* private fields */ }Expand description
Engulfing Pattern — detects bullish and bearish engulfing candlestick patterns.
A bullish engulfing occurs when:
- Previous bar is bearish (
prev_close < prev_open) - Current bar is bullish (
close > open) - Current bar’s body fully engulfs the prior bar’s body
(
open <= prev_closeandclose >= prev_open)
A bearish engulfing is the mirror: prior bullish, current bearish, full engulf.
Outputs:
+1→ bullish engulfing-1→ bearish engulfing0→ no pattern
Returns SignalValue::Unavailable on the first bar (requires prior bar).
§Example
use fin_primitives::signals::indicators::EngulfingPattern;
use fin_primitives::signals::Signal;
let ep = EngulfingPattern::new("ep").unwrap();
assert_eq!(ep.period(), 2);Implementations§
Trait Implementations§
Source§impl Signal for EngulfingPattern
impl Signal for EngulfingPattern
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 EngulfingPattern
impl RefUnwindSafe for EngulfingPattern
impl Send for EngulfingPattern
impl Sync for EngulfingPattern
impl Unpin for EngulfingPattern
impl UnsafeUnpin for EngulfingPattern
impl UnwindSafe for EngulfingPattern
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