# Triple Exponential Moving Average (TEMA)

> Layered Warm-Up and Signed Weights

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

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

## Signature

```ts
calculateTemaComponents(values, span)
```

Triple exponential moving average: `3 × EMA − 3 × EMA(EMA) + EMA(EMA(EMA))`. More lag cancellation than DEMA, and correspondingly more overshoot.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `values` | `(number \| null)[]` | yes | Observation series in chronological order, oldest first. · nulls: propagate |
| `span` | `number` | yes | Smoothing span used for all three EMA passes; the decay factor is 2 / (span + 1). · min: 1, integer: true |

## Returns

`{ ema1, ema2, ema3, tema }[]` · length same-as-input

One record per position carrying all three intermediate EMAs alongside the result.

## Warm-up

The first `3 × (span − 1)` positions are `null`. All three passes must fill before the combination is defined.

## Errors

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

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

`values`:

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

Showing 6 of 10 elements.

`span`:

```json
3
```

### Call

```ts
calculateTemaComponents(values, span)
```

### Returns

object with 4 fields: 6, 7, 8, 9

```json
{
  "6": {
    "ema1": 16.416666666666664,
    "ema2": 15.388888888888888,
    "ema3": 14.212962962962962,
    "tema": 17.29629629629629,
    "status": "ready"
  },
  "7": {
    "tema": 19.73495370370371,
    "status": "ready"
  },
  "8": {
    "tema": 19.311921296296298,
    "status": "ready"
  },
  "9": {
    "tema": 21.703703703703713,
    "status": "ready"
  }
}
```

## Other exports

`calculateTema`, `temaSteadyStateWeight`. 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/technical-indicators/trend-smoothing/tema/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/technical-indicators/trend-smoothing/tema/impl.ts
- Standalone repository: https://github.com/IslamBaraka90/Fintech-TEMA-Triple-Exponential-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
