# Percentage Price Oscillator (PPO)

> Normalize the MACD Spread

`D07-F02-A02` · Technical Indicators → Trend Systems · archetype `series-transform` · difficulty 2/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/technical-indicators/trend-systems/percentage-price-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 { ppo } from "fintech-algorithms/technical-indicators/trend-systems/percentage-price-oscillator";
```

## Signature

```ts
ppo(values, fastSpan, slowSpan, signalSpan)
```

MACD expressed as a percentage of the slow EMA rather than in price units, which makes readings comparable across instruments and across time in a way MACD is not.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `values` | `(number \| null)[]` | yes | Observation series in chronological order, oldest first. · nulls: propagate |
| `fastSpan` | `number` | yes | Span of the fast EMA. · min: 1, integer: true |
| `slowSpan` | `number` | yes | Span of the slow EMA; must exceed the fast span. · min: 1, integer: true |
| `signalSpan` | `number` | yes | Span of the EMA taken over the PPO line itself. · min: 1, integer: true |

## Returns

`Record<string, (number | null)[]>` · length same-as-input

Parallel series: `fast_ema`, `slow_ema`, `ppo`, `signal` and `histogram`.

## Warm-up

The first `slowSpan − 1 for the PPO line, and slowSpan + signalSpan − 2 for the signal and histogram` positions are `null`. As with MACD, the signal line is defined later than the line it smooths.

## Errors

- When any span is < 1, is not an integer, or fastSpan ≥ slowSpan — 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
[96.42, 96.948156, 97.568602, 98.255035, 98.973258, 99.68459]
```

Showing 6 of 180 elements.

`fastSpan`:

```json
12
```

`slowSpan`:

```json
26
```

`signalSpan`:

```json
9
```

### Call

```ts
ppo(values, fastSpan, slowSpan, signalSpan)
```

### Returns

object with 5 fields: fast_ema, slow_ema, ppo, signal, histogram

```json
{
  "fast_ema": [null, null, null, null, null, null],
  "slow_ema": [null, null, null, null, null, null],
  "ppo": [null, null, null, null, null, null],
  "signal": [null, null, null, null, null, null],
  "histogram": [null, null, null, null, null, null]
}
```

## 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-systems/percentage-price-oscillator/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/technical-indicators/trend-systems/percentage-price-oscillator/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/technical-indicators/llms.txt
