Exponential Moving Average (EMA)
Category: Trend · Updated November 2026
The TAAPI.IO EMA API returns the Exponential Moving Average as JSON for crypto pairs and US stocks. Send an exchange, symbol, timeframe and period to get real-time or historical values, with no candles to download and no calculations to maintain.
What one request returns
- The average (
value): an average of recent closes that weights the newest ones most. The default period is 30, andsourcelets you average the open, high or low instead. - A series, with
results: one value per candle, oldest first, for slopes, crossovers and backtests. - A stack of averages, with
/bulk: for example the 21, 50 and 200 EMA and the latest close in one request.
So one call answers two questions: is the market trending, and is price stretched away from its trend or pulling back to it?
Example: an uptrend that respected its 50 EMA, August to November 2026
Request: one /bulk call for AAPL on daily US stock candles, with the 21, 50 and 200-day EMA and the closing price. Sent at 22:37 UTC on Saturday 14 November, so the latest candle is Friday's close.
| Line | Value | Close vs line | Reading |
|---|---|---|---|
| Close, 13 Nov | 355.40 | — | Two trading days after the record close of 356.35 |
| EMA 21 | 345.95 | +2.7% | Short-term trend up |
| EMA 50 | 338.51 | +5.0% | Medium-term trend up |
| EMA 200 | 307.24 | +15.7% | Long-term trend up. 21 above 50 above 200: a stacked uptrend |
How to interpret this: AAPL rose from 325.14 on 1 September to a record close of 356.35 on 11 November, a gain of 9.3%. Through that run the 50-day EMA acted as a floor. 58 of the last 60 daily closes were above it. On 30 October the low touched it almost exactly, at 334.35 against an EMA of 334.31, and the stock closed at 345.10. The only closes below it since 17 August came on 2 and 3 November, at 328.81 and 329.82. On 4 November AAPL closed back above the line with a 6.4% gain, and a week later it set the record. For a trend follower, those two days were the pullback, not the end of the trend: the 21, 50 and 200 EMA stayed stacked in order the whole time. Today the close is 2.7% above the 21 EMA, so by the same rules there is no pullback to buy.
| Date | AAPL close | EMA 50 | What happened |
|---|---|---|---|
| 30 Oct | 345.10 | 334.31 | Low of 334.35 touched the EMA, close held above |
| 2 Nov | 328.81 | 334.10 | First close below the 50 EMA since 17 August |
| 3 Nov | 329.82 | 333.93 | Second close below |
| 4 Nov | 350.78 | 334.59 | Back above with a 6.4% gain |
| 11 Nov | 356.35 | 337.12 | Record close |
Values are from the production API on 14 November 2026, using daily closes. One pullback is an illustration, not a backtest. Nothing here is financial advice.
| Spec | Value |
|---|---|
| Endpoint | GET https://v2.taapi.io/indicator/ema |
| Outputs | EMA value, timestamp |
| Default settings | Period 30, source close |
| Markets | Binance, Binance Futures, Bybit, Gate.io, Kraken and US stocks |
| Timeframes | 1m to 1w |
| Delivery | REST, bulk and WebSocket |
Get EMA with one API call
This request returns EMA for BTCUSDT on 1-hour Binance candles. Add your API key to run it here.
curl -G https://v2.taapi.io/indicator/ema \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "exchange=binance" \ --data-urlencode "symbol=BTCUSDT" \ --data-urlencode "timeframe=1h"
import requests
resp = requests.get(
'https://v2.taapi.io/indicator/ema',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
params={'exchange': 'binance', 'symbol': 'BTCUSDT', 'timeframe': '1h'},
)
print(resp.json())const params = new URLSearchParams({"exchange": "binance", "symbol": "BTCUSDT", "timeframe": "1h"});
const res = await fetch(`https://v2.taapi.io/indicator/ema?${params}`, {
headers: { Authorization: 'Bearer YOUR_API_KEY' },
});
console.log(await res.json());EMA API response
This response came from the live API on 9 November 2026.
{
"value": [75084.74679900207],
"timestamp": [1794218400]
}| Field | Type | Description |
|---|---|---|
value | number[] | EMA result |
timestamp | integer[] | Unix time of each candle, in seconds |
EMA API parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
exchange | string | Yes | — | binance, binancefutures, bybit, gateio, kraken or stocks |
symbol | string | Yes | — | Pair or ticker, e.g. BTCUSDT or AAPL |
timeframe | string | Yes | — | 1m 5m 15m 1h 4h 1d 1w |
period | integer | No | 30 | Number of candles in the average |
source | string | No | close | Price to average: close, open, high or low |
results | integer | No | 1 | Number of values to return, or max |
backtrack | integer | No | 0 | Candles to skip from the most recent |
What is EMA?
The Exponential Moving Average is a moving average that gives more weight to recent prices, so it responds faster than a simple moving average of the same length. It is the building block of MACD and many other indicators.
EMA formula
| Output | Calculation |
|---|---|
| Multiplier | 2 ÷ (period + 1) |
| EMA | (close − previous EMA) × multiplier + previous EMA |
For the 21-day EMA the multiplier is 2 ÷ 22, about 0.091. In the example, the EMA was 345.00 on 12 November and AAPL closed at 355.40 on 13 November, so the new EMA is (355.40 − 345.00) × 0.091 + 345.00 = 345.95.
How to read EMA in your code
| Signal | Meaning | Condition |
|---|---|---|
| Price above average | Bullish bias | Close above value |
| Price below average | Bearish bias | Close below value |
| Stacked uptrend | Short, medium and long trend agree | EMA 21 above EMA 50 above EMA 200 |
| Pullback | Price back near its trend | Close between EMA 21 and EMA 50 in a stacked uptrend |
| Golden cross | Short-term trend overtakes long-term | EMA(50) crosses above EMA(200) |
| Death cross | Short-term trend falls under long-term | EMA(50) crosses below EMA(200) |
Limitations: An EMA depends on all earlier data, so values can differ slightly from a chart with a different amount of history. Like every average, it lags price, and a single close below it, as on 2 November, is often noise. Nothing on this page is financial advice.
EMA vs SMA
A simple moving average weights every candle in the window equally and forgets a candle completely when it leaves. An EMA weights the newest candle most, and older candles fade gradually without ever fully dropping out.
The multiplier sets how fast that happens. A 9-period EMA gives the latest close a weight of 20%, while a 200-period EMA gives it about 1%. So an EMA turns sooner than an SMA of the same length, which also means it reacts more to noise.
Using several EMAs together
Many systems compare averages rather than reading one alone. A fast EMA crossing a slow one marks a change in trend, and a stack such as 9 above 21 above 50 describes an orderly uptrend. Bulk requests are made for this: you can ask for several periods of the same indicator in one call, as long as each has its own id.
Crossovers are lagging by construction, because the averages can only cross after price has already moved. In ranges they produce repeated small losses, so many traders only use them alongside a measure of trend strength such as ADX.
Detect a 50/200 EMA golden cross with Python
One bulk request fetches both averages for the last two closed candles. Each indicator gets its own id, which becomes its key in the response.
curl -X POST https://v2.taapi.io/bulk \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"constructs": [
{
"id": "btc",
"exchange": "binance",
"symbol": "BTCUSDT",
"timeframe": "1h",
"indicators": [
{
"id": "ema50",
"indicator": "ema",
"period": 50,
"results": 2,
"backtrack": 1
},
{
"id": "ema200",
"indicator": "ema",
"period": 200,
"results": 2,
"backtrack": 1
}
]
}
]
}'import requests
resp = requests.post(
'https://v2.taapi.io/bulk',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
json={
"constructs": [
{
"id": "btc",
"exchange": "binance",
"symbol": "BTCUSDT",
"timeframe": "1h",
"indicators": [
{
"id": "ema50",
"indicator": "ema",
"period": 50,
"results": 2,
"backtrack": 1
},
{
"id": "ema200",
"indicator": "ema",
"period": 200,
"results": 2,
"backtrack": 1
}
]
}
]
},
)
data = resp.json()['btc']
fast_prev, fast = data['ema50']['value']
slow_prev, slow = data['ema200']['value']
if fast_prev <= slow_prev and fast > slow:
print('Golden cross')
elif fast_prev >= slow_prev and fast < slow:
print('Death cross')
else:
print('No cross,', 'fast above slow' if fast > slow else 'fast below slow')Check trend and pullback with three EMAs
A common trend-following rule: only buy when the 21, 50 and 200 EMA are stacked in order, and only when price has pulled back below the 21 EMA without closing below the 50. One /bulk request returns all three averages and the close. It uses one construct, so it works on every plan. For crypto, or for stocks during market hours, add backtrack=1 to each indicator.
curl -X POST https://v2.taapi.io/bulk \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"constructs": [
{
"id": "aapl_1d",
"exchange": "stocks",
"symbol": "AAPL",
"timeframe": "1d",
"indicators": [
{
"id": "ema21",
"indicator": "ema",
"period": 21
},
{
"id": "ema50",
"indicator": "ema",
"period": 50
},
{
"id": "ema200",
"indicator": "ema",
"period": 200
},
{
"id": "close",
"indicator": "price"
}
]
}
]
}'import requests
payload = {
"constructs": [
{
"id": "aapl_1d",
"exchange": "stocks",
"symbol": "AAPL",
"timeframe": "1d",
"indicators": [
{
"id": "ema21",
"indicator": "ema",
"period": 21
},
{
"id": "ema50",
"indicator": "ema",
"period": 50
},
{
"id": "ema200",
"indicator": "ema",
"period": 200
},
{
"id": "close",
"indicator": "price"
}
]
}
]
}
resp = requests.post(
'https://v2.taapi.io/bulk',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
json=payload,
)
data = resp.json()
c = data['aapl_1d']
close = c['close']['value'][-1]
e21, e50, e200 = (c[k]['value'][-1] for k in ('ema21', 'ema50', 'ema200'))
if e21 > e50 > e200:
if close < e50:
print('Uptrend, but the close is below the 50 EMA: wait')
elif close <= e21:
print('Uptrend pullback: the close is between the 21 and 50 EMA')
else:
print(f'Uptrend, close {(close / e21 - 1) * 100:.1f}% above the 21 EMA: no pullback yet')
else:
print('The EMAs are not stacked for an uptrend')The response at 22:37 UTC on 14 November. The averages are stacked and the close is above the 21 EMA, so the script prints Uptrend, close 2.7% above the 21 EMA: no pullback yet. On 3 November it would have printed Uptrend, but the close is below the 50 EMA: wait, and on 30 October, when AAPL closed between the two lines, Uptrend pullback: the close is between the 21 and 50 EMA.
{
"aapl_1d": {
"ema21": {
"value": [345.94999996903226],
"timestamp": [1794528000]
},
"ema50": {
"value": [338.5051075732595],
"timestamp": [1794528000]
},
"ema200": {
"value": [307.2411880702818],
"timestamp": [1794528000]
},
"close": {
"value": [355.4],
"timestamp": [1794528000]
}
}
}Pullback rules buy weakness inside a trend, so they lose when the trend ends. A common safeguard is to exit on a daily close below the 50 EMA, or below the 200 EMA for a slower system.
Get historical EMA values
Add results to return a series for backtesting or charting. The last element is the most recent candle.
curl -G https://v2.taapi.io/indicator/ema \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "exchange=binance" \ --data-urlencode "symbol=BTCUSDT" \ --data-urlencode "timeframe=1h" \ --data-urlencode "results=100"
Get EMA for multiple symbols
Combine EMA with other indicators in one request. Each exchange, symbol and timeframe combination is one construct: Basic allows 1 per request, Pro 3 and Expert 10.
curl -X POST https://v2.taapi.io/bulk \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"constructs": [
{
"id": "btc_1h",
"exchange": "binance",
"symbol": "BTCUSDT",
"timeframe": "1h",
"indicators": [
{
"id": "ema",
"indicator": "ema"
},
{
"id": "rsi",
"indicator": "rsi"
}
]
}
]
}'Stream EMA in real time
Subscribe over WebSocket to receive new values every 5 seconds while the candle is forming. Streaming supports 1m, 5m, 15m and 1h, and uses interval where REST uses timeframe.
{
"type": "subscribe",
"id": "ema",
"exchange": "binance",
"symbol": "BTCUSDT",
"interval": "1m",
"indicator": "ema"
}Common EMA settings
These are starting points, not recommendations. Test any setting on your own market and timeframe.
| Settings | Character | Typical use |
|---|---|---|
| 9, 21 | Fast | Intraday pullbacks and crossovers |
| 50 | Medium | Swing trend filter |
| 200 | Slow | Long-term trend filter |
Why EMA values can differ between platforms
- Warm-up history: An EMA depends on every earlier candle, so the amount of history behind a calculation affects the result. The effect is largest on long periods.
- Seed value: Platforms start the first EMA differently, commonly from an SMA or from the first close.
- Input price: The default input is the close. Use
sourceif your chart uses something else. - Exchange data: Each exchange has its own candles.
EMA API FAQ
What does the EMA API return?
An array of averages in value, plus a timestamp for each candle.
Can I get several EMA periods at once?
Yes. Send a POST /bulk request with several ema indicators, each with its own period and id. See Check trend and pullback with three EMAs.
Can I calculate the EMA of something other than the close?
Yes. Set source to open, high or low. The default is close.
Is the latest EMA value final?
No. The newest value belongs to the candle still forming and can change until it closes. Add backtrack=1 to read the last closed candle.
Can I get EMA for US stocks?
Yes. Use exchange=stocks with a ticker such as AAPL. US stocks are included on the Pro plan and above.
Related indicators
- Simple Moving Average (SMA): equal weights, slower to turn
- MACD: the gap between two EMAs
- SuperTrend: a trailing trend line
- ADX: trend strength, to filter crossovers
Build with EMA on Binance, Bybit or US stocks. Start for free or browse all 262 indicators.