---
id: "packages/active-charts/all-exports/indicators"
title: "Indicators"
description: "applyIndicators, EmaIndicator, IndicatorConfig, IndicatorResult and 2 more: generated from the source of active-charts."
url: "/packages/active-charts/all-exports/indicators"
locale: "en"
revision: "g0mvjxwj5c-88bdbe1c:indicators"
---

# Indicators

Exported by `@workspace/active-charts`. Generated from the package source; part of [the index of every export](/packages/active-charts/all-exports).

## Functions, hooks and constants

**applyIndicators**: `(data: ChartDatum[], indicators: IndicatorConfig[], t: ChartTranslateFn, defaultSourceKey?: string) => { enrichedData: ChartDatum[]; indicatorSeries: IndicatorResult[]; }`

Applies indicators to chart data, adding computed values as new keys on each datum.
Returns the enriched data (new array, original data untouched) plus metadata for
rendering the indicator series as lines.

Generated keys: `__sma_{period}`, `__ema_{period}`, `__macd_{fast}_{slow}` and
`__macd_signal_{fast}_{slow}_{signal}`. When an indicator's `sourceKey`
differs from `defaultSourceKey`, `_{sourceKey}` is appended (for example
`__sma_20_open`), so indicators of the same kind and period on different
source keys do not overwrite each other.

A period that is not a whole number of at least 1 yields `null` for every point.

## Types

**EmaIndicator**

```ts
interface EmaIndicator {
  type: 'ema';
  period: number;
  sourceKey?: string;
  stroke?: string;
  name?: string;
}
```

**IndicatorConfig**

```ts
type IndicatorConfig = SmaIndicator | EmaIndicator | MacdIndicator;
```

**IndicatorResult**

```ts
interface IndicatorResult {
  key: string;
  name: string;
  stroke: string;
  lineDash?: number[];
}
```

**MacdIndicator**

```ts
interface MacdIndicator {
  type: 'macd';
  fastPeriod?: number;
  slowPeriod?: number;
  signalPeriod?: number;
  sourceKey?: string;
  macdStroke?: string;
  signalStroke?: string;
  name?: string;
}
```

**SmaIndicator**

```ts
interface SmaIndicator {
  type: 'sma';
  period: number;
  sourceKey?: string;
  stroke?: string;
  name?: string;
}
```
