Moving Average Convergence Divergence (MACD)
Category: Momentum · Updated November 2026
The TAAPI.IO MACD API returns the Moving Average Convergence Divergence line, signal line and histogram as JSON for crypto pairs and US stocks. Send an exchange, symbol and timeframe to get real-time or historical MACD values, with no candles to download and no calculations to maintain.
What one request returns
- The three MACD values: the MACD line (
valueMACD), its signal line (valueMACDSignal) and the gap between them (valueMACDHist). The histogram's sign tells you which line is on top, so a change of sign is a crossover. - A series, with
results: one value per candle, oldest first, to spot a crossover between the last two closed candles or to backtest. - Several timeframes at once, with
/bulk: for example a 4-hour MACD for the signal and a daily MACD for the trend, in one request.
So one call answers two questions: which way is momentum pointing, and did it just turn?
Example: a 4-hour crossover against the daily trend, 11 November 2026
Request: one /bulk call for BTCUSDT on Binance, with MACD on 4-hour candles (results=3, backtrack=1, so the last three closed candles) and on daily candles (backtrack=1, so yesterday). Sent at 16:40 UTC with the default 12, 26, 9 settings.
| Candle | MACD | Signal | Histogram | Reading |
|---|---|---|---|---|
| 4h, 11 Nov 04:00 | −699.27 | −678.71 | −20.56 | MACD still below its signal line |
| 4h, 11 Nov 08:00 | −670.86 | −677.14 | +6.28 | Bullish crossover: the histogram turned positive |
| 4h, 11 Nov 12:00 | −640.99 | −669.91 | +28.92 | The gap is widening |
| 1d, 10 Nov | −1,799.33 | −1,416.71 | −382.62 | Below its signal line and below zero: downtrend |
How to interpret this: The 4-hour chart just gave the textbook buy signal. The histogram turned positive on the 08:00 candle and grew on the next one. The daily chart disagrees. Its MACD has been below the signal line since 29 September, when BTC closed at 83,664, and below zero since late October. BTC is down about 11% since then. In that trend, the same 4-hour signal had already fired six times in two weeks: 26 and 29 October, and 1, 3, 8 and 9 November. Each one ended lower by the next bearish crossover, by between 0.7% and 4.6%. The worst was 29 October, when BTC went from 81,778 to 77,992 in eight hours. All six, like today's, came with the MACD line below zero. So a trend-following bot would read today's crossover as a bounce, not a new uptrend. It would wait until the daily histogram turns positive, or the 4-hour MACD climbs above zero, before buying.
Values are from the production API on 11 November 2026. Crossovers are counted on closed 4-hour candles from 26 October. Six signals are an illustration, not a backtest, and nothing here is financial advice.
| Spec | Value |
|---|---|
| Endpoint | GET https://v2.taapi.io/indicator/macd |
| Outputs | MACD line, signal line, histogram, timestamp |
| Default settings | 12, 26, 9 |
| Markets | Binance, Binance Futures, Bybit, Gate.io, Kraken and US stocks |
| Timeframes | 1m to 1w |
| Delivery | REST, bulk and WebSocket |
Get MACD values with one API call
This request returns the current MACD for BTCUSDT on 1-hour Binance candles. Add your API key to run it here.
curl -G https://v2.taapi.io/indicator/macd \ -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/macd',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
params={'exchange': 'binance', 'symbol': 'BTCUSDT', 'timeframe': '1h'},
)
macd = resp.json()
print(macd['valueMACD'][-1], macd['valueMACDSignal'][-1], macd['valueMACDHist'][-1])const params = new URLSearchParams({ exchange: 'binance', symbol: 'BTCUSDT', timeframe: '1h' });
const res = await fetch(`https://v2.taapi.io/indicator/macd?${params}`, {
headers: { Authorization: 'Bearer YOUR_API_KEY' },
});
const { valueMACD, valueMACDSignal, valueMACDHist } = await res.json();MACD API response
Every value is returned in an array, even for a single candle. This response came from the live API on 9 November 2026.
{
"valueMACD": [-404.3589597536193],
"valueMACDSignal": [-335.59180677260025],
"valueMACDHist": [-68.76715298101902],
"timestamp": [1794218400]
}| Field | Type | Description |
|---|---|---|
valueMACD | number[] | MACD line: fast EMA minus slow EMA |
valueMACDSignal | number[] | Signal line: EMA of the MACD line |
valueMACDHist | number[] | Histogram: MACD line minus signal line |
timestamp | integer[] | Unix time of each candle, in seconds |
MACD 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 |
fastPeriod | integer | No | 12 | Fast EMA period |
slowPeriod | integer | No | 26 | Slow EMA period |
signalPeriod | integer | No | 9 | Signal line period |
results | integer | No | 1 | Number of values to return, or max |
backtrack | integer | No | 0 | Candles to skip from the most recent |
What is MACD?
MACD (Moving Average Convergence Divergence) is a trend-following momentum indicator developed by Gerald Appel. It compares two exponential moving averages to show the direction of a trend and whether momentum is building or fading.
MACD formula
| Output | Calculation |
|---|---|
| MACD line | 12-period EMA − 26-period EMA |
| Signal line | 9-period EMA of the MACD line |
| Histogram | MACD line − signal line |
In the response above, −404.36 minus −335.59 gives the histogram value of −68.77. A negative histogram means the MACD line is below its signal line.
How to read MACD in your code
| Signal | Meaning | Condition |
|---|---|---|
| Bullish crossover | Momentum turning up | valueMACDHist moves from ≤ 0 to > 0 |
| Bearish crossover | Momentum turning down | valueMACDHist moves from ≥ 0 to < 0 |
| Above zero | Fast EMA is above slow EMA | valueMACD > 0 |
| Below zero | Fast EMA is below slow EMA | valueMACD < 0 |
| Momentum fading | Trend is losing strength | Absolute histogram value shrinking |
A divergence appears when price makes a new high but MACD makes a lower high, or the reverse at lows. It can warn of a reversal, but it needs a series of values to detect, so request them with results.
Limitations: MACD is built from moving averages, so it lags price and can produce repeated false crossovers in sideways markets. Many traders confirm it with a trend or volume filter. Nothing on this page is financial advice.
Detect a MACD crossover with Python
The newest value belongs to the candle still forming and can change until it closes. To avoid acting on a signal that disappears, use backtrack=1 and compare the last two closed candles. Arrays run oldest first.
curl -G https://v2.taapi.io/indicator/macd \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "exchange=binance" \ --data-urlencode "symbol=BTCUSDT" \ --data-urlencode "timeframe=1h" \ --data-urlencode "results=2" \ --data-urlencode "backtrack=1"
import requests
resp = requests.get(
'https://v2.taapi.io/indicator/macd',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
params={'exchange': 'binance', 'symbol': 'BTCUSDT', 'timeframe': '1h',
'results': 2, 'backtrack': 1},
)
prev, last = resp.json()['valueMACDHist']
if prev <= 0 < last:
print('Bullish MACD crossover')
elif prev >= 0 > last:
print('Bearish MACD crossover')
else:
print('No crossover')Filter crossovers with a higher timeframe
Crossovers on short timeframes fire often, and in a trend most of the ones against it fail, as in the example above. A common fix is to take a signal only when a higher timeframe agrees: a 4-hour crossover with the daily histogram on the same side of zero, or a 15-minute crossover with the 1-hour histogram. One /bulk request returns both. Two constructs need the Pro plan or above. On Basic, make two GET requests instead.
curl -X POST https://v2.taapi.io/bulk \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"constructs": [
{
"id": "btc_4h",
"exchange": "binance",
"symbol": "BTCUSDT",
"timeframe": "4h",
"indicators": [
{
"id": "macd",
"indicator": "macd",
"results": 2,
"backtrack": 1
}
]
},
{
"id": "btc_1d",
"exchange": "binance",
"symbol": "BTCUSDT",
"timeframe": "1d",
"indicators": [
{
"id": "macd",
"indicator": "macd",
"backtrack": 1
}
]
}
]
}'import requests
payload = {
"constructs": [
{
"id": "btc_4h",
"exchange": "binance",
"symbol": "BTCUSDT",
"timeframe": "4h",
"indicators": [
{
"id": "macd",
"indicator": "macd",
"results": 2,
"backtrack": 1
}
]
},
{
"id": "btc_1d",
"exchange": "binance",
"symbol": "BTCUSDT",
"timeframe": "1d",
"indicators": [
{
"id": "macd",
"indicator": "macd",
"backtrack": 1
}
]
}
]
}
resp = requests.post(
'https://v2.taapi.io/bulk',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
json=payload,
)
data = resp.json()
prev, last = data['btc_4h']['macd']['valueMACDHist']
daily = data['btc_1d']['macd']['valueMACDHist'][-1]
if prev <= 0 < last:
if daily > 0:
print('Bullish 4h crossover with the daily trend')
else:
print('Bullish 4h crossover against the daily trend: skip')
elif prev >= 0 > last:
if daily < 0:
print('Bearish 4h crossover with the daily trend')
else:
print('Bearish 4h crossover against the daily trend: skip')
else:
print('No crossover')The response at 16:40 UTC on 11 November. Both 4-hour histogram values are already positive, because the crossover happened one candle earlier, between the 04:00 candle (−20.56) and the 08:00 candle (+6.28). So this response prints No crossover. Run at 12:05 UTC, when 08:00 was the last closed candle, the same script printed Bullish 4h crossover against the daily trend: skip. Run it once per closed candle so you don't miss one.
{
"btc_4h": {
"macd": {
"valueMACD": [-670.8607757510617, -640.9926914345997],
"valueMACDSignal": [-677.1391784198927, -669.909881022834],
"valueMACDHist": [6.2784026688309496, 28.91718958823435],
"timestamp": [1794384000, 1794398400]
}
},
"btc_1d": {
"macd": {
"valueMACD": [-1799.3266097731102],
"valueMACDSignal": [-1416.7087529977862],
"valueMACDHist": [-382.61785677532407],
"timestamp": [1794268800]
}
}
}Other common filters: take bullish crossovers only above the zero line (valueMACD > 0), require the histogram to grow for two candles in a row, or check the trend with a 200-period EMA.
Get historical MACD 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/macd \ -H "Authorization: Bearer YOUR_API_KEY" \ --data-urlencode "exchange=binance" \ --data-urlencode "symbol=BTCUSDT" \ --data-urlencode "timeframe=4h" \ --data-urlencode "results=100"
Get MACD for multiple symbols
Use bulk to combine symbols, timeframes and MACD settings 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": "macd", "indicator": "macd" },
{ "id": "macd_fast", "indicator": "macd", "fastPeriod": 8, "slowPeriod": 21, "signalPeriod": 5 }
]
}]
}'Stream MACD 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": "btc-macd",
"exchange": "binance",
"symbol": "BTCUSDT",
"interval": "1m",
"indicator": "macd",
"params": { "fastPeriod": 12, "slowPeriod": 26, "signalPeriod": 9 }
}{
"type": "update",
"subscription": "binance:btcusdt:1m",
"data": {
"binance_btcusdt_1m_btc-macd": {
"valueMACD": [12.41],
"valueMACDSignal": [10.96],
"valueMACDHist": [1.45],
"timestamp": [1782389580]
}
}
}Common MACD settings
These are starting points, not recommendations. Test any setting on your own market and timeframe.
| Settings | Character | Typical use |
|---|---|---|
| 12, 26, 9 | Standard | Default for most timeframes |
| 8, 21, 5 | Faster, more signals | Short intraday charts |
| 5, 35, 5 | Wider EMA gap | Clearer trend separation |
Why MACD values can differ between platforms
- Data source: each exchange has its own candles, so a Binance MACD will differ from a Coinbase chart.
- Open candle: a forming candle changes the latest value on every update.
- Calculation history: EMAs depend on how much earlier data they start from.
- Signal type: some platforms, including MetaTrader's default MACD, use an SMA for the signal line. TAAPI.IO's
macduses an EMA for the signal line, as Gerald Appel defined it.
API status codes
{
"valueMACD": [142.83],
"valueMACDSignal": [98.21],
"valueMACDHist": [44.62],
"timestamp": [1718233200]
}{ "pending": true, "key": "ta:binance:BTCUSDT:1h:macd:..." }{ "error": "Missing required: exchange, symbol, timeframe" }{ "error": "Invalid or inactive token" }{ "error": "Too Many Requests", "retryAfter": 9 }MACD API FAQ
What does the MACD API return?
Three arrays, valueMACD, valueMACDSignal and valueMACDHist, plus a timestamp for each candle.
Is the latest MACD value final?
No. The newest value belongs to the candle still forming and changes until it closes. Add backtrack=1 to read the last closed candle.
How do I avoid false MACD crossovers?
Take a crossover only when a higher timeframe agrees, for example a 4-hour crossover with the daily valueMACDHist on the same side of zero. Use backtrack=1 so you act on closed candles only. See Filter crossovers with a higher timeframe.
Can I change the MACD periods?
Yes. Set fastPeriod, slowPeriod and signalPeriod. The defaults are 12, 26 and 9.
Can I get MACD for stocks as well as crypto?
Yes. Use exchange=stocks with a ticker such as AAPL. US stocks are included on the Pro plan and above.
Can I get MACD for many symbols at once?
Yes. POST /bulk accepts several symbols and timeframes in one request, up to your plan's construct limit.
Related indicators
- Exponential Moving Average (EMA): the building block of MACD
- Relative Strength Index (RSI): momentum confirmation
- MACD with controllable MA type (MACDEXT): choose the average per line
- Volume Split: buy and sell volume behind a move
Build with MACD on Binance, Bybit or US stocks. Start for free or browse all 262 indicators.