> For the complete documentation index, see [llms.txt](https://nighostchris.gitbook.io/traders/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nighostchris.gitbook.io/traders/categories/technicalanalysislibrary/exponential-moving-average-ema.md).

# Exponential Moving Average (EMA)

A type of moving average that places a greater weight and significance on the most recent data points. (credit to Investopia)

{% tabs %}
{% tab title="JavaScript" %}

```javascript
import { Ticker, TechnicalAnalysisLibrary } from 'traders';

const ticker = new Ticker('V');

const data = await ticker.historical('1d', '2021-02-15', '2021-03-11');

const ta = new TechnicalAnalysisLibrary();

try {
  const result = ta.EMA(5, data);
} catch (error) {
  console.log(error);
}
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
import { HistoricalData, Ticker, TechnicalAnalysisLibrary } from 'traders';

const ticker = new Ticker('V');

const data: HistoricalData[] | undefined = await ticker.historical('1d', '2021-02-15', '2021-03-11');

const ta = new TechnicalAnalysisLibrary();

try {
  const result = ta.EMA(5, data);
} catch (error) {
  console.log(error);
}
```

{% endtab %}
{% endtabs %}

```bash
# Example of EMA result on
# Visa daily closing price from 2021-02-15 to 2021-03-11
[
  209.0766668701172,
  212.52777547200526,
  212.93518364800352,
  212.75345556188518,
  214.04563866886096,
  214.62042720339429,
  214.69695350343474,
  213.6313023356232,
  214.22420277778525,
  216.23946994267715,
  217.61298016523529,
  219.4653194998053
]
```
