Knowledge Base/What is a moving average convergence divergence (MACD)?

What is a moving average convergence divergence (MACD)?

MACD is the gap between a fast and a slow exponential moving average, plotted with its own signal line. Massive returns three numbers per point: the MACD value, the signal, and the histogram between them.

Moving average convergence divergence (MACD) is the fast exponential moving average minus the slow one. It is positive when the fast average is above the slow one and negative when below, and it moves away from zero as the two pull apart and back toward zero as they converge, which is why traders read it as a momentum gauge. Massive calculates it for you on the macd indicator endpoint, so you pass a ticker, a timespan and three separate windows rather than pulling bars and computing it yourself.

Applies to

  • Plans: every plan, including the free Basic tier.
  • Endpoints: /v1/indicators/macd/{ticker}, with timespan, short_window, long_window and signal_window.
  • Asset classes: stocks, options, indices, forex and crypto, using that asset class's ticker format.

How to call it

curl -X GET "https://api.massive.com/v1/indicators/macd/AAPL?timespan=day&short_window=12&long_window=26&signal_window=9&limit=1&apiKey=YOUR_API_KEY"

Response

{
  "results": {
    "values": [
      { "timestamp": 1789012800000, "value": 2.3605662226668187, "signal": 1.5719231323333052, "histogram": 0.7886430903335135 }
    ]
  },
  "status": "OK"
}

MACD does not take a single window, because it is built from two moving averages and a signal line. It takes short_window, long_window and signal_window, which default to 12, 26 and 9. Passing window instead is ignored rather than refused, so you silently get the defaults.

How to read it

The three outputs answer different questions. value is the gap between the averages, signal is the smoothed version of that gap, and histogram is the difference between the two, which is what crosses zero when the MACD crosses its signal line.

Choosing the windows

Shorter windows react sooner and produce more signals, most of which are noise; longer ones are steadier and later. The 12, 26 and 9 defaults are a convention rather than a finding. Pick them from the horizon you actually trade or analyze on, keep them consistent, and resist tuning them until the history looks good, which is the quickest route to a result that does not repeat.

If you see an error

A response with no values in results means the endpoint could not compute a point for the time you asked for, not that your date range was too short. Common causes are a timestamp that matches no bar (a weekend, a market holiday, or a millisecond value that is not the start of a bar), a lowercase ticker, and a ticker whose whole history has fewer bars than long_window, such as a recent listing. MACD cannot produce its first point until long_window bars have closed, and its signal line needs signal_window more after that.

A jump on a single date is usually a stock split rather than the market. Bars are split-adjusted by default, so mixing adjusted and unadjusted history will show up here.

{"status":"NOT_AUTHORIZED"} is about the asset class rather than the indicator: it follows the same subscription as the bars underneath.

Related


Was this article helpful?

Modernizing Wall St.

Reimagining financial market data for the 21st century.

Schedule a demo

Talk with our market data experts

Recommended

Can't find the answer you're looking for? Contact our team.
  • Title
    Are all indices available through the basic subscription tier?
    Data Coverage Category

    Data Coverage

    Indices Category

    Indices

    Description
    No, and the ones it withholds are the famous ones: SPX, DJI, RUT and VIX all need a paid Indices tier. Basic still reaches more than 10,000 of the 13,000-odd indices Massive publishes, and NDX and the Nasdaq Composite are among them.
  • Title
    Does Massive offer dark pool data?
    Data Coverage Category

    Data Coverage

    Stocks Category

    Stocks

    Description
    Yes. Off-exchange prints, which include dark pool executions, arrive on the ordinary trades feed and are identified by an exchange ID of 4. There is no separate dark pool endpoint, and no way to tell which individual venue a print came from.
  • Title
    Does Massive offer pre-market and after-hours data?
    FAQ Category

    FAQ

    Stocks Category

    Stocks

    Description
    Yes. Every extended-hours trade and quote is published, from 04:00 to 20:00 Eastern. There is no session parameter, so you select a session with timestamps, and expect far fewer aggregate bars outside regular hours because many extended-hours trades are odd lots that cannot set a price.