fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Three Black Crows

Install and import#

bash
npm install fintech-algorithms
ts
import { threeBlackCrows } from "fintech-algorithms/price-action-and-candlesticks/multi-candle-patterns/three-black-crows";

Signature#

threeBlackCrows(inputs)

Evaluates exactly three candles against explicit black-crows body, close, shadow, scale, and uptrend conventions.

Parameters#

NameTypeNotes
inputs{ candles: { open: number; high: number; low: number; close: number }[]; trend_context: string; prior_bodies: number[]; prior_ranges: number[]; tick_size: number; penetration_fraction: number }Record containing three candles, trend context, prior body/range history, tick size, and penetration fraction.

Returns#

{ topic_id, pattern, matched, state, direction, trend_context, required_context, history_count, body_scale, range_scale, geometry_score, checks, failed_checks, reason, thresholds, candles }

One three-candle pattern record. state is warmup, wrong-context, matched, or not-matched; readiness is record state, not positional output.

Warm-up#

The first 5 prior observations positions are state: warmup. The detector returns one readiness record before five prior body/range observations are available; it does not emit a positional null prefix.

Errors#

  • When the record does not contain exactly three valid candles or scale/context inputs are invalid — throws

Complexity: time , space .

Worked example#

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input#

inputs
{
  "candles": [
    {
      "open": 105,
      "high": 105.2,
      "low": 102.8,
      "close": 103
    },
    {
      "open": 103.5,
      "high": 103.7,
      "low": 101.3,
      "close": 101.5
    },
    {
      "open": 102,
      "high": 102.2,
      "low": 99.8,
      "close": 100
    }
  ],
  "trend_context": "uptrend",
  "prior_bodies": [2, 2.1, 1.9, 2.2, 2, 2.1],
  "prior_ranges": [3, 3.2, 2.9, 3.1, 3, 3.3],
  "tick_size": 0.1,
  "penetration_fraction": 0.5
}

Call#

threeBlackCrows(inputs)

Returns#

object with 16 fields: topic_id, pattern, matched, state, direction, trend_context, required_context, history_count, …

{
  "topic_id": "D06-F04-A04",
  "pattern": "Three Black Crows",
  "matched": true,
  "state": "matched",
  "direction": "bearish",
  "trend_context": "uptrend",
  "required_context": "uptrend",
  "history_count": 10,
  "body_scale": 2,
  "range_scale": 3,
  "geometry_score": 1,
  "checks": {
    "three_bearish": true,
    "material_bodies": true,
    "falling_closes": true,
    "second_opens_in_prior_body": true,
    "third_opens_in_prior_body": true,
    "short_lower_shadows": true
  },
  "failed_checks": [],
  "reason": "all declared checks pass"
}

Showing 14 of 16 fields.

Other exports#

This module also exports calculate, morningStar, eveningStar, threeWhiteSoldiers, threeInsideUpDown, threeOutsideUpDown, abandonedBaby. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams#

Three Black Crows — system map

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

The rest of the Multi-Candle Patterns family#