# `TAlib.Indicators.CDL`
[🔗](https://github.com/benyblack/talib/blob/main/lib/indicators/cdl.ex#L1)

Candlestick pattern recognition (TA-Lib Pattern Recognition group),
translated bar for bar from TA-Lib's C definitions.

Every function takes bars — maps with at least `:open`, `:high`,
`:low` and `:close`, oldest first — and returns one score per bar,
aligned with the input: `100` bullish, `-100` bearish, `0` no
pattern. Bars inside the pattern's lookback score `0`. The hikkake
functions follow TA-Lib's confirmation convention: the bar that
confirms a recent setup scores `±200` (the setup's direction), and
`engulfing`/`harami`/`harami_cross` score `±80` when the touching
bodies are merely equal rather than strictly engulfing.

Thresholds are TA-Lib's global candle settings, applied exactly as
the C library applies them (each average covers the bars *before*
the candle being judged):

  - bodies are long/short against the average real body of the
    10 previous candles (factor 1.0), very long at 3x;
  - a doji body is under 10% of the average high-low range of the
    10 previous candles;
  - a shadow is long beyond the candle's own real body, very long
    beyond 2x, short under half the average shadow sum of the 10
    previous candles, very short under 10% of the average high-low
    range;
  - "near"/"far"/"equal" distances are 20%/60%/5% of the average
    high-low range of the 5 previous candles.

The `penetration` parameters are fractions of the reference body,
defaulting like TA-Lib (0.3 for the star patterns, 0.5 for the
rest). See `TAlib` for the remaining conventions.

# `abandoned_baby`

```elixir
@spec abandoned_baby([map()], number()) :: [integer()]
```

Abandoned Baby: a long candle, a doji gapping away from it, and a
third candle gapping beyond the doji to close well within the first
body.

    iex> TAlib.Indicators.CDL.abandoned_baby([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `advance_block`

```elixir
@spec advance_block([map()]) :: [integer()]
```

Advancing Block: three white candles with higher closes but stalling
bodies or upper shadows.

    iex> TAlib.Indicators.CDL.advance_block([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `belt_hold`

```elixir
@spec belt_hold([map()]) :: [integer()]
```

Belt Hold: a long-body candle with a very short shadow on the
closing end.

    iex> bars = Enum.map(0..9, fn _ -> %{open: 0.0, high: 2.0, low: 0.0, close: 1.0} end)
    iex> TAlib.Indicators.CDL.belt_hold(bars) |> Enum.all?(&(&1 == 0))
    true

# `breakaway`

```elixir
@spec breakaway([map()]) :: [integer()]
```

Breakaway: a gap and three drifting candles, then a long candle
closing back inside the gap.

    iex> TAlib.Indicators.CDL.breakaway([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `closing_marubozu`

```elixir
@spec closing_marubozu([map()]) :: [integer()]
```

Closing Marubozu: a long body with a very short shadow only on the
closing end.

    iex> bars = Enum.map(0..9, fn _ -> %{open: 0.0, high: 2.0, low: 0.0, close: 1.0} end)
    iex> TAlib.Indicators.CDL.closing_marubozu(bars) |> Enum.all?(&(&1 == 0))
    true

# `conceal_babys_wall`

```elixir
@spec conceal_babys_wall([map()]) :: [integer()]
```

Concealing Baby Swallow: two marubozu blacks, a gapping black with
an upper shadow into the prior body, engulfed by the fourth black.

    iex> TAlib.Indicators.CDL.conceal_babys_wall([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `context`

```elixir
@spec context([map()]) :: %TAlib.Indicators.CDL.Ctx{bars: term(), raw: term()}
```

Build the candle context of `bars` once, for reuse across several
pattern calls (each pattern called with plain bars rebuilds it).

    iex> ctx = TAlib.Indicators.CDL.context([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    iex> TAlib.Indicators.CDL.doji(ctx)
    [0]

# `counterattack`

```elixir
@spec counterattack([map()]) :: [integer()]
```

Counterattack: two opposite long candles closing at the same level.

    iex> TAlib.Indicators.CDL.counterattack([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `dark_cloud_cover`

```elixir
@spec dark_cloud_cover([map()], number()) :: [integer()]
```

Dark Cloud Cover: a long white candle, then a black opening above
its high and closing well within its body.

    iex> TAlib.Indicators.CDL.dark_cloud_cover([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `doji`

```elixir
@spec doji([map()]) :: [integer()]
```

Doji: a body no wider than 10% of the average high-low range of the
10 previous candles.

    iex> bars = Enum.map(0..9, fn _ -> %{open: 0.0, high: 2.0, low: 0.0, close: 1.0} end)
    iex> TAlib.Indicators.CDL.doji(bars ++ [%{open: 1.0, high: 2.0, low: 0.0, close: 1.01}]) |> List.last()
    100

# `doji_star`

```elixir
@spec doji_star([map()]) :: [integer()]
```

Doji Star: a long candle then a doji gapping away from its body.

    iex> TAlib.Indicators.CDL.doji_star([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `dragonfly_doji`

```elixir
@spec dragonfly_doji([map()]) :: [integer()]
```

Dragonfly Doji: a doji with a very short upper shadow and a lower
shadow beyond the very-short band.

    iex> TAlib.Indicators.CDL.dragonfly_doji([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `engulfing`

```elixir
@spec engulfing([map()]) :: [integer()]
```

Engulfing: a candle whose body engulfs the previous opposite-color
body — `±80` when the touching bodies are merely equal.

    iex> TAlib.Indicators.CDL.engulfing([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `evening_doji_star`

```elixir
@spec evening_doji_star([map()], number()) :: [integer()]
```

Evening Doji Star: a long white, a doji gapping up, then a black
closing well within the first body.

    iex> TAlib.Indicators.CDL.evening_doji_star([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `evening_star`

```elixir
@spec evening_star([map()], number()) :: [integer()]
```

Evening Star: a long white, a short candle gapping up, then a black
closing well within the first body.

    iex> TAlib.Indicators.CDL.evening_star([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `gap_side_side_white`

```elixir
@spec gap_side_side_white([map()]) :: [integer()]
```

Upside/Downside Gap Side-by-Side White Lines: two white candles on
the same side of a gap, of near-equal body and open.

    iex> TAlib.Indicators.CDL.gap_side_side_white([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `gravestone_doji`

```elixir
@spec gravestone_doji([map()]) :: [integer()]
```

Gravestone Doji: a doji with a very short lower shadow and an upper
shadow beyond the very-short band.

    iex> TAlib.Indicators.CDL.gravestone_doji([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `hammer`

```elixir
@spec hammer([map()]) :: [integer()]
```

Hammer: a small body near the prior candle's lows with a long lower
shadow and a very short upper shadow.

    iex> TAlib.Indicators.CDL.hammer([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `hanging_man`

```elixir
@spec hanging_man([map()]) :: [integer()]
```

Hanging Man: a small body near the prior candle's highs with a long
lower shadow and a very short upper shadow.

    iex> TAlib.Indicators.CDL.hanging_man([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `harami`

```elixir
@spec harami([map()]) :: [integer()]
```

Harami: a long candle then a short body inside it — `±80` when the
short body merely touches the long body's ends.

    iex> TAlib.Indicators.CDL.harami([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `harami_cross`

```elixir
@spec harami_cross([map()]) :: [integer()]
```

Harami Cross: a long candle then a doji inside it — `±80` when the
doji merely touches the long body's ends.

    iex> TAlib.Indicators.CDL.harami_cross([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `high_wave`

```elixir
@spec high_wave([map()]) :: [integer()]
```

High Wave: a short body with both shadows longer than twice the
body.

    iex> TAlib.Indicators.CDL.high_wave([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `hikkake`

```elixir
@spec hikkake([map()]) :: [integer()]
```

Hikkake: an inside bar resolved by a breakout bar, with a `±200`
confirmation when a close crosses the setup's extreme within three
bars.

    iex> bars = [
    ...>   %{open: 1.0, high: 10.0, low: 0.0, close: 5.0},
    ...>   %{open: 1.0, high: 9.0, low: 1.0, close: 5.0},
    ...>   %{open: 1.0, high: 8.0, low: 0.5, close: 5.0},
    ...>   %{open: 1.0, high: 8.5, low: 0.6, close: 5.0},
    ...>   %{open: 1.0, high: 8.4, low: 0.7, close: 5.0},
    ...>   %{open: 1.0, high: 8.6, low: 0.65, close: 9.5}
    ...> ]
    iex> TAlib.Indicators.CDL.hikkake(bars)
    [0, 0, 0, 0, 0, 200]

# `hikkake_mod`

```elixir
@spec hikkake_mod([map()]) :: [integer()]
```

Modified Hikkake: two consecutive inside bars with the second
closing near its extreme, resolved by a breakout bar, with the same
`±200` confirmation as `hikkake/1`.

    iex> TAlib.Indicators.CDL.hikkake_mod([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `homing_pigeon`

```elixir
@spec homing_pigeon([map()]) :: [integer()]
```

Homing Pigeon: a long black candle then a smaller black body inside
it.

    iex> TAlib.Indicators.CDL.homing_pigeon([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `identical_3_crows`

```elixir
@spec identical_3_crows([map()]) :: [integer()]
```

Identical Three Crows: three black candles with very short lower
shadows, each opening at the prior close and closing lower.

    iex> TAlib.Indicators.CDL.identical_3_crows([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `in_neck`

```elixir
@spec in_neck([map()]) :: [integer()]
```

In Neck: a long black, then a white opening below its low and
closing marginally into its body.

    iex> TAlib.Indicators.CDL.in_neck([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `inverted_hammer`

```elixir
@spec inverted_hammer([map()]) :: [integer()]
```

Inverted Hammer: after a gap down, a small body with a long upper
shadow and a very short lower shadow.

    iex> TAlib.Indicators.CDL.inverted_hammer([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `kicking`

```elixir
@spec kicking([map()]) :: [integer()]
```

Kicking: two opposite marubozu candles separated by a body gap.

    iex> TAlib.Indicators.CDL.kicking([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `kicking_by_length`

```elixir
@spec kicking_by_length([map()]) :: [integer()]
```

Kicking (determined by length): as `kicking/1`, scored by the color
of the longer body.

    iex> TAlib.Indicators.CDL.kicking_by_length([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `ladder_bottom`

```elixir
@spec ladder_bottom([map()]) :: [integer()]
```

Ladder Bottom: three blacks with lower opens and closes, a black
with an upper shadow, then a white closing above its high.

    iex> TAlib.Indicators.CDL.ladder_bottom([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `long_legged_doji`

```elixir
@spec long_legged_doji([map()]) :: [integer()]
```

Long Legged Doji: a doji with at least one shadow longer than its
own body.

    iex> TAlib.Indicators.CDL.long_legged_doji([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `long_line`

```elixir
@spec long_line([map()]) :: [integer()]
```

Long Line: a long body with short shadows on both ends.

    iex> bars = Enum.map(0..9, fn _ -> %{open: 0.0, high: 2.0, low: 0.0, close: 1.0} end)
    iex> TAlib.Indicators.CDL.long_line(bars) |> Enum.all?(&(&1 == 0))
    true

# `marubozu`

```elixir
@spec marubozu([map()]) :: [integer()]
```

Marubozu: a long body with very short shadows on both ends.

    iex> bars = Enum.map(0..9, fn _ -> %{open: 0.0, high: 2.0, low: 0.0, close: 1.0} end)
    iex> TAlib.Indicators.CDL.marubozu(bars) |> Enum.all?(&(&1 == 0))
    true

# `mat_hold`

```elixir
@spec mat_hold([map()], number()) :: [integer()]
```

Mat Hold: a long white, a gap and three small drifting candles
holding within it, then a white closing above the reaction highs.

    iex> TAlib.Indicators.CDL.mat_hold([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `matching_low`

```elixir
@spec matching_low([map()]) :: [integer()]
```

Matching Low: two black candles closing at the same level.

    iex> TAlib.Indicators.CDL.matching_low([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `morning_doji_star`

```elixir
@spec morning_doji_star([map()], number()) :: [integer()]
```

Morning Doji Star: a long black, a doji gapping down, then a white
closing well within the first body.

    iex> TAlib.Indicators.CDL.morning_doji_star([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `morning_star`

```elixir
@spec morning_star([map()], number()) :: [integer()]
```

Morning Star: a long black, a short candle gapping down, then a
white closing well within the first body.

    iex> TAlib.Indicators.CDL.morning_star([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `on_neck`

```elixir
@spec on_neck([map()]) :: [integer()]
```

On Neck: a long black, then a white opening below its low and
closing at its low.

    iex> TAlib.Indicators.CDL.on_neck([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `piercing`

```elixir
@spec piercing([map()], number()) :: [integer()]
```

Piercing Line: a long black, then a white opening below its low and
closing above the midpoint of its body.

    iex> TAlib.Indicators.CDL.piercing([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `rickshaw_man`

```elixir
@spec rickshaw_man([map()]) :: [integer()]
```

Rickshaw Man: a doji with long shadows on both sides and the body
near the midpoint of the range.

    iex> TAlib.Indicators.CDL.rickshaw_man([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `rise_fall_3_methods`

```elixir
@spec rise_fall_3_methods([map()]) :: [integer()]
```

Rising/Falling Three Methods: a long candle, three small bodies
drifting within it, then a long candle closing the move.

    iex> TAlib.Indicators.CDL.rise_fall_3_methods([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `scan`

```elixir
@spec scan([map()], [atom()]) :: %{required(atom()) =&gt; [integer()]}
```

Score several patterns over one shared context — equivalent to
calling each pattern on `bars`, without rebuilding the trailing
sums per pattern. With no pattern list, scores all 61.

    iex> bars = Enum.map(0..9, fn _ -> %{open: 0.0, high: 2.0, low: 0.0, close: 1.0} end)
    iex> TAlib.Indicators.CDL.scan(bars ++ [%{open: 1.0, high: 2.0, low: 0.0, close: 1.01}], [:doji])[:doji] |> List.last()
    100

# `separating_lines`

```elixir
@spec separating_lines([map()]) :: [integer()]
```

Separating Lines: two opposite candles opening at the same level,
the second a belt-hold candle.

    iex> TAlib.Indicators.CDL.separating_lines([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `shooting_star`

```elixir
@spec shooting_star([map()]) :: [integer()]
```

Shooting Star: after a body gap up, a small body with a long upper
shadow and a very short lower shadow.

    iex> TAlib.Indicators.CDL.shooting_star([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `short_line`

```elixir
@spec short_line([map()]) :: [integer()]
```

Short Line: a short body with short shadows on both ends.

    iex> bars = Enum.map(0..9, fn _ -> %{open: 0.0, high: 2.0, low: 0.0, close: 1.0} end)
    iex> TAlib.Indicators.CDL.short_line(bars) |> Enum.all?(&(&1 == 0))
    true

# `spinning_top`

```elixir
@spec spinning_top([map()]) :: [integer()]
```

Spinning Top: a short body with both shadows longer than the body
itself.

    iex> TAlib.Indicators.CDL.spinning_top([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `stalled_pattern`

```elixir
@spec stalled_pattern([map()]) :: [integer()]
```

Stalled Pattern: two long whites advancing, then a small body
riding on the second candle's shoulder.

    iex> TAlib.Indicators.CDL.stalled_pattern([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `stick_sandwich`

```elixir
@spec stick_sandwich([map()]) :: [integer()]
```

Stick Sandwich: two blacks around a white whose low holds above the
first close, the closes matching.

    iex> TAlib.Indicators.CDL.stick_sandwich([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `takuri`

```elixir
@spec takuri([map()]) :: [integer()]
```

Takuri: a doji with a very short upper shadow and a lower shadow
longer than twice the body.

    iex> TAlib.Indicators.CDL.takuri([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `tasuki_gap`

```elixir
@spec tasuki_gap([map()]) :: [integer()]
```

Tasuki Gap: a gap then a candle opening inside the gap-closing
direction with a near-equal body, closing inside the gap.

    iex> TAlib.Indicators.CDL.tasuki_gap([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `three_black_crows`

```elixir
@spec three_black_crows([map()]) :: [integer()]
```

Three Black Crows: three long black candles opening inside the prior
body, closing successively lower with very short lower shadows.

    iex> TAlib.Indicators.CDL.three_black_crows([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `three_inside`

```elixir
@spec three_inside([map()]) :: [integer()]
```

Three Inside: a long candle, a short candle engulfed by it, then a
candle closing out in the opposite direction.

    iex> TAlib.Indicators.CDL.three_inside([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `three_line_strike`

```elixir
@spec three_line_strike([map()]) :: [integer()]
```

Three Line Strike: three same-color candles each opening near the
prior body, undone by a fourth that opens beyond and closes across
all three.

    iex> TAlib.Indicators.CDL.three_line_strike([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `three_outside`

```elixir
@spec three_outside([map()]) :: [integer()]
```

Three Outside: an engulfing candle followed by a further close in
the engulfing direction.

    iex> TAlib.Indicators.CDL.three_outside([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `three_stars_in_south`

```elixir
@spec three_stars_in_south([map()]) :: [integer()]
```

Three Stars in the South: three black candles — long with a long
lower shadow, smaller inside it, then a small marubozu engulfed by
the second.

    iex> TAlib.Indicators.CDL.three_stars_in_south([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `three_white_soldiers`

```elixir
@spec three_white_soldiers([map()]) :: [integer()]
```

Three Advancing White Soldiers: three white candles with consecutive
higher closes, each opening near the prior body, none far shorter
than its predecessor.

    iex> bars = Enum.map(0..11, fn _ -> %{open: 0.0, high: 2.0, low: 0.0, close: 1.0} end)
    iex> TAlib.Indicators.CDL.three_white_soldiers(bars) |> Enum.all?(&(&1 == 0))
    true

# `thrusting`

```elixir
@spec thrusting([map()]) :: [integer()]
```

Thrusting: a long black, then a white opening below its low and
closing into but under the midpoint of its body.

    iex> TAlib.Indicators.CDL.thrusting([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `tristar`

```elixir
@spec tristar([map()]) :: [integer()]
```

Tristar: three dojis, the second gapping away and the third failing
to extend the gap.

    iex> TAlib.Indicators.CDL.tristar([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `two_crows`

```elixir
@spec two_crows([map()]) :: [integer()]
```

Two Crows: two black candles gapping up after a long white one, the
third closing inside the first body.

    iex> TAlib.Indicators.CDL.two_crows([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `unique_3_river`

```elixir
@spec unique_3_river([map()]) :: [integer()]
```

Unique Three River: a long black, a black harami with a lower low,
then a small white opening off the low.

    iex> TAlib.Indicators.CDL.unique_3_river([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `upside_gap_2crows`

```elixir
@spec upside_gap_2crows([map()]) :: [integer()]
```

Upside Gap Two Crows: a long white, then two blacks gapping up with
the third engulfing the second but closing above the first.

    iex> TAlib.Indicators.CDL.upside_gap_2crows([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

# `xside_gap_3methods`

```elixir
@spec xside_gap_3methods([map()]) :: [integer()]
```

Upside/Downside Gap Three Methods: a gap between two same-color
candles, partially closed by a third of the opposite color.

    iex> TAlib.Indicators.CDL.xside_gap_3methods([%{open: 1, high: 2, low: 0.5, close: 1.5}])
    [0]

---

*Consult [api-reference.md](api-reference.md) for complete listing*
