# Traditional McClellan Oscillator

> Compare Fast and Slow Raw Breadth

`D04-F02-A01` · Market Breadth and Internals → McClellan Family · archetype `record-transform` · difficulty 3/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/market-breadth-and-internals/mcclellan-family/traditional-mcclellan-oscillator/
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 { calculateMcClellanValues } from "fintech-algorithms/market-breadth-and-internals/mcclellan-family/traditional-mcclellan-oscillator";
```

## Signature

```ts
calculateMcClellanValues(netAdvances)
```

The difference between a 19-day and a 39-day EMA of net advances. Because both averages are taken over raw counts, values are not comparable across eras in which the number of listed issues changed — which is exactly what the ratio-adjusted variant fixes.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `netAdvances` | `number[]` | yes | Net advances per session, chronological. |

## Returns

`{ ema19, ema39, oscillator }`

Both EMAs alongside the oscillator, so a reading can be traced to its components.

## Errors

- When fewer sessions are supplied than the longer EMA needs — returns nulls during warm-up rather than throwing

## Complexity

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

## Worked example

This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

### Input

`netAdvances`:

```json
[0, 0, 0, 0, 0, 0]
```

Showing 6 of 44 elements.

### Call

```ts
calculateMcClellanValues(netAdvances)
```

### Returns

object with 6 fields: 38, 39, 40, 41, 42, 43

```json
{
  "38": {
    "observation": 39,
    "fast_ema": 0,
    "slow_ema": 0,
    "oscillator": 0,
    "status": "ready"
  },
  "39": {
    "observation": 40,
    "fast_ema": 10,
    "slow_ema": 5,
    "oscillator": 5,
    "status": "ready"
  },
  "40": {
    "observation": 41,
    "fast_ema": 19,
    "slow_ema": 9.75,
    "oscillator": 9.25,
    "status": "ready"
  },
  "41": {
    "observation": 42,
    "fast_ema": 7.1,
    "slow_ema": 4.2625,
    "oscillator": 2.8375,
    "status": "ready"
  },
  "42": {
    "observation": 43,
    "fast_ema": 6.39,
    "slow_ema": 4.049375,
    "oscillator": 2.340625,
    "status": "ready"
  },
  "43": {
    "observation": 44,
    "fast_ema": -4.249,
    "slow_ema": -1.15309375,
    "oscillator": -3.09590625,
    "status": "ready"
  }
}
```

## Other exports

`calculateMcClellan`. 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.

## Verification and provenance

Tier: **verified** (via input-expected).

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/mcclellan-family/traditional-mcclellan-oscillator/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/market-breadth-and-internals/mcclellan-family/traditional-mcclellan-oscillator/impl.ts
- Standalone repository: https://github.com/IslamBaraka90/Fintech-McClellan-Oscillator-Market-Breadth-algorithm
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/market-breadth-and-internals/llms.txt
