# Parabolic SAR

> Audit the Stop, Extreme Point, and Acceleration Factor

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

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

## Signature

```ts
parabolicSar(high, low, initialDirection, accelerationStep, accelerationMax)
```

Stop-and-reverse: a trailing stop that accelerates toward price while a trend persists and flips side when price crosses it. Path-dependent — the whole series follows from the initial direction.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `high` | `number[]` | yes | Per-bar high prices, chronological. |
| `low` | `number[]` | yes | Per-bar low prices, chronological. |
| `initialDirection` | `"long" \| "short"` | yes | Trend direction assumed at the first bar. Because the calculation is recursive, this choice propagates through the entire series. |
| `accelerationStep` | `number` | yes | Increment added to the acceleration factor each time a new extreme is made. · min: 0 |
| `accelerationMax` | `number` | yes | Ceiling on the acceleration factor. · min: 0 |

## Returns

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

Parallel series: `sar`, `trend`, `extreme_point`, `acceleration_factor` and a `reversal` flag marking the bars where the stop flipped.

## Warm-up

The first `1` positions are `null`. The first bar establishes the state; the first SAR value applies from the second.

## Errors

- When accelerationStep or accelerationMax is negative, or accelerationStep > accelerationMax — 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

`high`:

```json
[117.555, 118.215368, 118.945956, 119.686391, 120.381031, 120.987562]
```

Showing 6 of 180 elements.

`low`:

```json
[115.1985, 115.34324, 115.864377, 116.536001, 117.321542, 118.15831]
```

Showing 6 of 180 elements.

`initialDirection`:

```json
"long"
```

`accelerationStep`:

```json
0.02
```

`accelerationMax`:

```json
0.2
```

### Call

```ts
parabolicSar(high, low, initialDirection, accelerationStep, accelerationMax)
```

### Returns

object with 5 fields: sar, trend, extreme_point, acceleration_factor, reversal

```json
{
  "sar": [null, 115.1985, 115.1985, 115.34324, 115.60382906, 115.9860052152],
  "trend": [null, "long", "long", "long", "long", "long"],
  "extreme_point": [null, 118.215368, 118.945956, 119.686391, 120.381031, 120.987562],
  "acceleration_factor": [null, 0.02, 0.04, 0.06, 0.08, 0.1],
  "reversal": [null, false, false, false, false, false]
}
```

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