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

Tweezer Bottom

Install and import#

bash
npm install fintech-algorithms
ts
import { tweezerBottom } from "fintech-algorithms/price-action-and-candlesticks/two-candle-patterns/tweezer-bottom";

Signature#

tweezerBottom(inputs)

Evaluates two candles against explicit tweezer-bottom tolerance, rejection, scale, and downtrend conventions.

Parameters#

NameTypeNotes
inputs{ first: { open: number; high: number; low: number; close: number }; second: { open: number; high: number; low: number; close: number }; prior_bodies: number[]; prior_ranges: number[]; trend_context: string; tick_size: number; price_tolerance_ticks: number }Record containing first, second, prior body/range history, context, tick size, and price tolerance.

Returns#

{ topic_id, pattern, matched, state, direction, trend_context, required_context, body, upper_shadow, lower_shadow, range, body_scale, range_scale, history_count, geometry_score, checks, failed_checks, first_direction, second_direction, first_body, second_body, first_body_low?, first_body_high?, second_body_low?, second_body_high?, first_high?, second_high?, first_low?, second_low?, midpoint?, price_tolerance }

One pattern record with causal geometry diagnostics. state is warmup, wrong-context, matched, or not-matched; detailed price fields are absent during warmup.

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 candle, history, context, tick-size, or tolerance input violates the data contract — 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
{
  "first": {
    "open": 102,
    "high": 102.2,
    "low": 99,
    "close": 100
  },
  "second": {
    "open": 99.9,
    "high": 101.7,
    "low": 99.1,
    "close": 101.5
  },
  "prior_bodies": [2, 2.2, 1.8, 2.1, 1.9, 2],
  "prior_ranges": [5, 5, 5, 5, 5, 5],
  "trend_context": "downtrend",
  "tick_size": 0.1,
  "price_tolerance_ticks": 2
}

Call#

tweezerBottom(inputs)

Returns#

object with 31 fields: topic_id, pattern, matched, state, direction, trend_context, required_context, body, …

{
  "topic_id": "D06-F03-A08",
  "pattern": "Tweezer Bottom",
  "matched": true,
  "state": "matched",
  "direction": "bullish",
  "trend_context": "downtrend",
  "required_context": "downtrend",
  "body": 1.5999999999999943,
  "upper_shadow": 0.20000000000000284,
  "lower_shadow": 0.8000000000000114,
  "range": 2.6000000000000085,
  "body_scale": 2,
  "range_scale": 5,
  "history_count": 10
}

Showing 14 of 31 fields.

Other exports#

This module also exports calculate, shadowToBodyRatio, gapClassification, trendContextFilter, doji, dragonflyDoji, gravestoneDoji, marubozu, spinningTop, hammer, hangingMan, invertedHammer, shootingStar, bullishEngulfing, bearishEngulfing, bullishHarami, bearishHarami, piercingLine, darkCloudCover, tweezerTop. 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#

Tweezer Bottom — 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 Two-Candle Patterns family#