tulip_rs 0.1.15

High-performance technical analysis library — 100+ indicators and 60+ candlestick patterns with SIMD acceleration
Documentation
///Southern Doji
/// Construction:
///    a doji candle with at least one shadow
///    if the candle prior this pattern is of doji type, pattern's body has to be below it
///    if the candle prior this pattern is not a doji candle then
///        in the case of a black candle, opening on the next candle cannot be higher than the closing on the previous candle
///        in the case of a white candle, opening on the next candle cannot be higher than the opening on the previous candle
///    the high price above the low price of the previous candle
///    the high price at the level or below of the trendline
///    length of the shadows is not important
use crate::candle_indicators::{
    pattern_test::EmaState,
    registry::CandleBits,
    types::{CandleInfo, ForecastType},
};
use tulip_rs_macros::pattern_template;

use super::FIRST;

pub fn info() -> CandleInfo {
    CandleInfo {
        name: "sourtherndoji",
        full_name: "Southern Doji",
        forecast: ForecastType::BullishReversal,
        extended_pattern: None,
        bars: 1,
        japanese_name: "Minami no Doji",
    }
}

#[pattern_template(
    name = "SouthernDoji",
    forecast = "BullishReversal",
    prev_bar(trend = "DOWN"),
    bar(
        colour = "RED",
        candle_type = "Doji(LongLeggedDoji | DragonflyDoji | GravestoneDoji | Doji)",
        body_gap = "GAP_DOWN"
    )
)]

pub fn calc(
    inputs: (&[f64], &[f64], &[f64], &[f64]),
    state: &EmaState,
    _bars: &[CandleBits],
) -> bool {
    let (_, high, _, _) = inputs;

    high[FIRST] <= state.get_ema()
}