# Zweig Breadth Thrust

`D04-F04-A01` · Market Breadth and Internals → Thrust and Pressure · archetype `record-transform` · difficulty 4/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/market-breadth-and-internals/thrust-and-pressure/zweig-breadth-thrust/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { calculate } from "fintech-algorithms/market-breadth-and-internals/thrust-and-pressure/zweig-breadth-thrust";
```

## Signature

```ts
calculate(rows, emaLength, lowThreshold, highThreshold, maxSessions)
```

Detects the rare initiation signal: the advance ratio moving from below a low threshold to above a high one inside a bounded number of sessions. It fires a handful of times in a generation, which is the point — and also why it cannot be validated on a short sample.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `rows` | `Row[]` | yes | Sessions carrying advances and declines. Rows carry a `ready` flag; a row that is not ready is excluded rather than treated as zero, because a missing count and a count of zero mean opposite things about market breadth. |
| `emaLength` | `number` | yes | EMA length applied to the advance ratio. Zweig's original is 10. · min: 1, integer: true |
| `lowThreshold` | `number` | yes | The ratio the EMA must fall below to arm the signal. Conventionally 0.40. · min: 0 |
| `highThreshold` | `number` | yes | The ratio it must then exceed. Conventionally 0.615. · min: 0 |
| `maxSessions` | `number` | yes | Maximum sessions permitted between the two crossings; beyond it the move is not a thrust. · min: 1, integer: true |

## Returns

`{ status, trigger_date, ema, sessions, series }`

The trigger date if one occurred, with the EMA path and session count so a near-miss can be seen rather than merely absent.

## Errors

- When lowThreshold ≥ highThreshold — throws

## Complexity

Time `O(n)`, space `O(n)`.

## Worked example

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`:

```json
[
  {
    "session_date": "2026-01-05",
    "advances": 520,
    "declines": 480,
    "ready": true
  },
  {
    "session_date": "2026-01-06",
    "advances": 500,
    "declines": 500,
    "ready": true
  },
  {
    "session_date": "2026-01-07",
    "advances": 480,
    "declines": 520,
    "ready": true
  }
]
```

Showing 3 of 24 elements.

`emaLength`:

```json
10
```

`lowThreshold`:

```json
0.4
```

`highThreshold`:

```json
0.615
```

`maxSessions`:

```json
10
```

### Call

```ts
calculate(rows, emaLength, lowThreshold, highThreshold, maxSessions)
```

### Returns

object with 5 fields: status, trigger_date, ema, sessions, series

```json
{
  "status": "thrust",
  "trigger_date": "2026-01-28",
  "ema": 0.6648021169863199,
  "sessions": 6,
  "series": [
    {
      "date": "2026-01-05",
      "ratio": 0.52,
      "ema": 0.52,
      "state": "idle"
    },
    {
      "date": "2026-01-06",
      "ratio": 0.5,
      "ema": 0.5163636363636364,
      "state": "idle"
    },
    {
      "date": "2026-01-07",
      "ratio": 0.48,
      "ema": 0.5097520661157025,
      "state": "idle"
    }
  ]
}
```

## Verification and provenance

Tier: **verified** (via row-fixture).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.1.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/market-breadth-and-internals/thrust-and-pressure/zweig-breadth-thrust/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/market-breadth-and-internals/thrust-and-pressure/zweig-breadth-thrust/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/market-breadth-and-internals/llms.txt
