fintech-algorithms

Breadth-Divergence Detector

Install and import

bash
npm install fintech-algorithms
ts
import { calculate } from "fintech-algorithms/market-breadth-and-internals/thrust-and-pressure/breadth-divergence-detector";

Signature

calculate(rows, left, right, minPriceChange, minBreadthSeparation, breadthScale)

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

rows
[
  {
    "session_date": "2026-01-05",
    "index_level": 100,
    "breadth_value": 500,
    "ready": true
  },
  {
    "session_date": "2026-01-06",
    "index_level": 101,
    "breadth_value": 520,
    "ready": true
  },
  {
    "session_date": "2026-01-07",
    "index_level": 102,
    "breadth_value": 540,
    "ready": true
  }
]

Showing 3 of 36 elements.

left
2
right
2
minPriceChange
0.01
minBreadthSeparation
0.05
breadthScale
1000

Call

calculate(rows, left, right, minPriceChange, minBreadthSeparation, breadthScale)

Returns

object with 2 fields: status, events

{
  "status": "bearish",
  "events": [
    {
      "status": "bearish",
      "first_pivot_date": "2026-01-19",
      "second_pivot_date": "2026-02-05",
      "confirmation_date": "2026-02-09",
      "price_change": 0.05454545454545454,
      "breadth_separation": -0.13,
      "breadth_scale": 1000
    }
  ]
}

Diagrams

Breadth-Divergence Detector — decision boundary
Breadth-Divergence Detector — family 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

  • Claim-to-source map
  • Advance/Decline Indicator — Fidelity
  • Advance-Decline Volume Line — StockCharts ChartSchool
  • Advance-Decline Indicators — StockCharts ChartSchool
  • Historical-example decision