pub trait CandlePatterns {
// Required methods
fn is_hammer(&self) -> bool;
fn is_inverted_hammer(&self) -> bool;
fn is_shooting_star(&self) -> bool;
fn is_spinning_top(&self) -> bool;
fn is_marubozu(&self) -> bool;
fn is_bullish_engulfing(&self, prev: &Bar) -> bool;
fn is_bearish_engulfing(&self, prev: &Bar) -> bool;
fn is_morning_star(&self, prev1: &Bar, prev2: &Bar) -> bool;
fn is_evening_star(&self, prev1: &Bar, prev2: &Bar) -> bool;
}Expand description
Extension trait for candlestick pattern detection
Required Methods§
Sourcefn is_hammer(&self) -> bool
fn is_hammer(&self) -> bool
Returns true if this is a hammer pattern
Hammer characteristics:
- Small body (< 30% of range)
- Long lower wick (> 2x body)
- Little to no upper wick
- Typically appears in downtrends (bullish reversal)
Sourcefn is_inverted_hammer(&self) -> bool
fn is_inverted_hammer(&self) -> bool
Returns true if this is an inverted hammer pattern
Inverted Hammer characteristics:
- Small body (< 30% of range)
- Long upper wick (> 2x body)
- Little to no lower wick
- Typically appears in downtrends (bullish reversal)
Sourcefn is_shooting_star(&self) -> bool
fn is_shooting_star(&self) -> bool
Returns true if this is a shooting star pattern
Shooting Star characteristics:
- Small body (< 30% of range)
- Long upper wick (> 2x body)
- Little to no lower wick
- Body is near the low
- Typically appears in uptrends (bearish reversal)
Sourcefn is_spinning_top(&self) -> bool
fn is_spinning_top(&self) -> bool
Returns true if this is a spinning top pattern
Spinning Top characteristics:
- Small body (< 30% of range)
- Upper and lower wicks of similar length
- Indicates indecision in the market
Sourcefn is_marubozu(&self) -> bool
fn is_marubozu(&self) -> bool
Returns true if this is a marubozu (very long body, little to no wicks)
Marubozu characteristics:
- Large body (> 85% of range)
- Very small or no wicks
- Strong directional move
Sourcefn is_bullish_engulfing(&self, prev: &Bar) -> bool
fn is_bullish_engulfing(&self, prev: &Bar) -> bool
Returns true if current bar engulfs the previous bar (bullish engulfing)
Bullish Engulfing:
- Previous bar is bearish
- Current bar is bullish
- Current body completely engulfs previous body
Sourcefn is_bearish_engulfing(&self, prev: &Bar) -> bool
fn is_bearish_engulfing(&self, prev: &Bar) -> bool
Returns true if current bar engulfs the previous bar (bearish engulfing)
Bearish Engulfing:
- Previous bar is bullish
- Current bar is bearish
- Current body completely engulfs previous body
Sourcefn is_morning_star(&self, prev1: &Bar, prev2: &Bar) -> bool
fn is_morning_star(&self, prev1: &Bar, prev2: &Bar) -> bool
Returns true if this forms a morning star pattern with two previous bars
Morning Star (bullish reversal):
- Large bearish candle
- Small-bodied candle (gap down)
- Large bullish candle
Sourcefn is_evening_star(&self, prev1: &Bar, prev2: &Bar) -> bool
fn is_evening_star(&self, prev1: &Bar, prev2: &Bar) -> bool
Returns true if this forms an evening star pattern with two previous bars
Evening Star (bearish reversal):
- Large bullish candle
- Small-bodied candle (gap up)
- Large bearish candle
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".