Skip to main content

CandlePatterns

Trait CandlePatterns 

Source
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§

Source

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)
Source

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)
Source

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)
Source

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
Source

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
Source

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
Source

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
Source

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):

  1. Large bearish candle
  2. Small-bodied candle (gap down)
  3. Large bullish candle
Source

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):

  1. Large bullish candle
  2. Small-bodied candle (gap up)
  3. Large bearish candle

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§