# Hull MA

`D07-F01-A07` · Technical Indicators → Trend Smoothing · archetype `series-transform` · difficulty 2/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/technical-indicators/trend-smoothing/hull-ma/
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 { calculateHullMa } from "fintech-algorithms/technical-indicators/trend-smoothing/hull-ma";
```

## Signature

```ts
calculateHullMa(values, window)
```

Hull moving average: a weighted combination of two WMAs de-lagged against each other, then re-smoothed over sqrt(window). Far more responsive than an SMA of the same length, at the cost of overshoot.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `values` | `(number \| null)[]` | yes | Observation series in chronological order, oldest first. · nulls: propagate |
| `window` | `number` | yes | Base window; the internal halved window and the sqrt(window) smoothing window derive from it. · min: 1, integer: true |

## Returns

`(number | null)[]` · length same-as-input

Smoothed series, `null` during the combined warm-up of all three stages.

## Warm-up

The first `window + ceil(sqrt(window)) - 2` positions are `null`. Warm-up positions are null rather than a partial result, so a consumer never mistakes an incomplete window for a real value.

## Errors

- When window < 1 or is not an integer — throws RangeError

## 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

`values`:

```json
[10, 13, 12, 15, 14, 18]
```

Showing 6 of 10 elements.

`window`:

```json
5
```

### Call

```ts
calculateHullMa(values, window)
```

### Returns

object with 6 fields: halfLength, rootLength, shortWma, longWma, rawHull, hullMa

```json
{
  "halfLength": 2,
  "rootLength": 2,
  "shortWma": [null, 12, 12.333333333333334, 14, 14.333333333333334, 16.666666666666668],
  "longWma": [null, null, null, null, 13.466666666666667, 15.2],
  "rawHull": [null, null, null, null, 15.200000000000001, 18.133333333333336],
  "hullMa": [null, null, null, null, null, 17.15555555555556]
}
```

## Verification and provenance

Tier: **verified** (via scenario-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/technical-indicators/trend-smoothing/hull-ma/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/technical-indicators/trend-smoothing/hull-ma/impl.ts
- Standalone repository: https://github.com/IslamBaraka90/Fintech-HMA-Hull-Moving-Average-algorithm
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/technical-indicators/llms.txt
