use crate::candle_indicators::registry::CandleBits;
use crate::candle_indicators::{
pattern_test::EmaState,
types::{CandleInfo, ForecastType},
};
use tulip_rs_macros::pattern_template;
use super::FIRST;
pub fn info() -> CandleInfo {
CandleInfo {
name: "hangingman",
full_name: "Hanging Man",
forecast: ForecastType::BearishReversal,
extended_pattern: None,
bars: 1,
japanese_name: "kubitsuri",
}
}
#[pattern_template(
name = "HangingMan",
forecast = "BearishReversal",
prev_bar(trend = "UP")
bar(
body_height = "SHORT",
line_height = "LONG",
upper_wick_lt_body = "TRUE",
lower_wick_lt_body = "FALSE",
candle_type = "!Doji(Doji | LongLeggedDoji | DragonflyDoji | GravestoneDoji | FourPriceDoji)"
)
)]
pub fn calc(
inputs: (&[f64], &[f64], &[f64], &[f64]),
state: &EmaState,
_bars: &[CandleBits],
) -> bool {
let (open, _, _, close) = inputs;
if !(state.get_ema() < close[FIRST] && state.get_ema() < open[FIRST]) {
return false;
}
true
}