GET/indicator/sma

Simple Moving Average (SMA)

Category: Trend · Updated November 2026


The TAAPI.IO SMA API returns the Simple 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): the mean of the last period closes, 30 by default.
  • A series, with results: one value per candle, oldest first, to see the slope or find where two averages crossed.
  • Several periods at once, with /bulk: the 50-day and 200-day SMA together, each with its own id, plus the closing price.

So one call answers two questions: which way is the trend, and has the long-term picture changed?

Example: a death cross that kept rising, April to November 2026

Request: one /bulk call for TSLA on daily US stock candles, with the 50-day and 200-day SMA (results=2, so the last two closes) and the closing price. Sent at 22:37 UTC on Saturday 14 November, so the latest daily candle is Friday's close and no backtrack is needed.

CandleTSLA closeSMA 50SMA 200Reading
12 Nov399.85373.98382.4650-day below the 200-day: the death cross is in effect
13 Nov387.11374.23382.26Close above both averages, 50-day still 8.02 below

How to interpret this: TSLA's 50-day SMA crossed below its 200-day on 9 April 2026, at a close of 344.94. That is the textbook death cross, a long-term sell signal. Seven months later it is still in effect, yet TSLA closed at 387.11 on 13 November, 12.2% higher and above both averages. In between, the stock rose to 448.20 by 13 May, 30% above the death cross, then fell to 296.64 by 29 July, and crossed its 200-day SMA 11 times. The golden cross before it, on 16 September 2025 at 422.89, had the same problem in reverse: TSLA went on to 490.57 in December, then gave it all back, and the death cross came 18.4% below the golden cross. A 200-day average moves slowly, so crosses of the 50-day and 200-day arrive months after the move they describe. They tell you which regime a market has been in, not where it goes next.

TSLA daily closes with the 50-day and 200-day SMA, September 2025 to November 2026 A golden cross on 16 September 2025 at 422.89 was followed by a death cross on 9 April 2026 at 344.94. After the death cross TSLA rose to 448.20 in May, fell to 296.64 in July and closed at 387.11 on 13 November, above both averages, while the 50-day SMA stayed below the 200-day. 300 350 400 450 500 Oct Nov Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Golden cross, 16 Sep 2025: 422.89 Death cross, 9 Apr 2026: 344.94 448.20, 13 May: +30% after the death cross 296.64, 29 Jul 13 Nov: 387.11, above both averages, still no golden cross Close SMA 50 SMA 200 Golden cross Death cross TSLA · US stocks, daily closes · SMA 50 and SMA 200 · Sep 2025 – 13 Nov 2026
TSLA daily closes (grey) with the 50-day SMA (blue) and 200-day SMA (amber). The green circle marks the golden cross and the red circle the death cross, which was still in effect on 13 November.
CrossDateTSLA closeWhat came next
Golden16 Sep 2025422.89High of 490.57 on 16 Dec, then the death cross 18.4% lower
Death9 Apr 2026344.94High of 448.20 on 13 May (+29.9%), low of 296.64 on 29 Jul (−14.0%)
None since13 Nov 2026387.1112.2% above the death cross, above both averages

Values are from the production API on 14 November 2026, using daily closes. Two crosses are an illustration, not a backtest. Nothing here is financial advice.

SpecValue
EndpointGET https://v2.taapi.io/indicator/sma
OutputsSMA value, timestamp
Default settingsPeriod 30
MarketsBinance, Binance Futures, Bybit, Gate.io, Kraken and US stocks
Timeframes1m to 1w
DeliveryREST, bulk and WebSocket

Get SMA with one API call

This request returns SMA for BTCUSDT on 1-hour Binance candles. Add your API key to run it here.

curl -G https://v2.taapi.io/indicator/sma \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --data-urlencode "exchange=binance" \
  --data-urlencode "symbol=BTCUSDT" \
  --data-urlencode "timeframe=1h"

SMA API response

This response came from the live API on 9 November 2026.

200 OK
{
  "value": [75299.52233333327],
  "timestamp": [1794218400]
}
FieldTypeDescription
valuenumber[]SMA result
timestampinteger[]Unix time of each candle, in seconds

SMA API parameters

NameTypeRequiredDefaultDescription
exchangestringYes—binance, binancefutures, bybit, gateio, kraken or stocks
symbolstringYes—Pair or ticker, e.g. BTCUSDT or AAPL
timeframestringYes—1m 5m 15m 1h 4h 1d 1w
periodintegerNo30Number of closes in the average
resultsintegerNo1Number of values to return, or max
backtrackintegerNo0Candles to skip from the most recent

What is SMA?

The Simple Moving Average is the arithmetic mean of the last n closes. It is the most widely used trend filter, and the middle line of Bollinger Bands.

SMA formula

OutputCalculation
SMASum of the last n closes ÷ n
Next SMAPrevious SMA + (newest close − close leaving the window) ÷ n

The second line is why an SMA can move even when price doesn't: a large close leaving the window changes the average as much as a large close entering it. TSLA's 50-day SMA of 374.23 on 13 November is exactly the sum of its last 50 closes divided by 50, and its 200-day SMA of 382.26 the same over 200.

How to read SMA in your code

SignalMeaningCondition
Price above averageBullish biasClose above value
Price below averageBearish biasClose below value
SlopeDirection of the trendLatest value versus the previous one
Golden crossShort-term average overtakes long-termSMA(50) crosses above SMA(200)
Death crossShort-term average falls under long-termSMA(50) crosses below SMA(200)

Limitations: Every candle in the window has equal weight, so a large candle moves the average twice: when it enters and when it leaves. Long averages lag by design, as in the example above. Nothing on this page is financial advice.

Price against the average, or the cross?

There are two common ways to use a long average. The first compares price with it: above the 200-day SMA is an uptrend, below it a downtrend. That reacts within a day, but it flips often. TSLA crossed its 200-day 11 times between April and November. The second waits for a faster average to cross the slower one. That flips rarely, but late. Many systems use the cross to decide the regime and price against a shorter average for timing.

Detect a golden or death cross with Python

One /bulk request returns both averages for the last two candles and the latest close. Each indicator gets its own id, which becomes its key in the response. It uses one construct, so it works on every plan. For crypto, or for stocks during market hours, add backtrack=1 to each indicator so you compare closed candles only.

POST/bulk
curl -X POST https://v2.taapi.io/bulk \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "constructs": [
    {
      "id": "tsla_1d",
      "exchange": "stocks",
      "symbol": "TSLA",
      "timeframe": "1d",
      "indicators": [
        {
          "id": "sma50",
          "indicator": "sma",
          "period": 50,
          "results": 2
        },
        {
          "id": "sma200",
          "indicator": "sma",
          "period": 200,
          "results": 2
        },
        {
          "id": "close",
          "indicator": "price"
        }
      ]
    }
  ]
}'

The response at 22:37 UTC on 14 November. The 50-day stayed below the 200-day on both candles, so there is no new cross, and the script prints No new cross. The death cross is in effect, and the close of 387.11 is above the 200-day SMA (382.26).

200 OK
{
  "tsla_1d": {
    "sma50": {
      "value": [373.984018, 374.233496],
      "timestamp": [1794441600, 1794528000]
    },
    "sma200": {
      "value": [382.4641704999992, 382.25721699999923],
      "timestamp": [1794441600, 1794528000]
    },
    "close": {
      "value": [387.1093],
      "timestamp": [1794528000]
    }
  }
}

To find past crosses for a backtest, request a longer series, for example results=300, and compare each pair of neighbouring values. Other common filters: require price to close on the same side of the 200-day SMA as the cross, or confirm it with MACD.

Get historical SMA 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/sma \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --data-urlencode "exchange=binance" \
  --data-urlencode "symbol=BTCUSDT" \
  --data-urlencode "timeframe=1h" \
  --data-urlencode "results=100"

Get SMA for multiple symbols

Combine SMA 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.

POST/bulk
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": "sma",
          "indicator": "sma"
        },
        {
          "id": "rsi",
          "indicator": "rsi"
        }
      ]
    }
  ]
}'

Stream SMA 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.

WSSwss://v2.taapi.io/streaming
{
  "type": "subscribe",
  "id": "sma",
  "exchange": "binance",
  "symbol": "BTCUSDT",
  "interval": "1m",
  "indicator": "sma"
}

Common SMA settings

These are starting points, not recommendations. Test any setting on your own market and timeframe.

SettingsCharacterTypical use
20Short-termBase of Bollinger Bands
50MediumSwing trend filter
200Long-termLong-term trend filter

Why SMA values can differ between platforms

  • Exchange data: each exchange has its own closes, so a Binance SMA differs from another venue's.
  • Open candle: the newest value changes until the candle closes. Use backtrack=1 to read closed candles.
  • Stock data: daily stock candles cover the regular session, so an SMA can differ from a chart that includes pre-market and after-hours trading.

SMA API FAQ

What does the SMA API return?

An array of averages in value, plus a timestamp for each candle.

How do I get the 50-day and 200-day SMA together?

Send a POST /bulk request with two sma indicators, one with "period": 50 and one with "period": 200, each with its own id. See Detect a golden or death cross with Python.

Is a death cross a sell signal?

It marks a change of regime, and it arrives late. In the example above, TSLA rose 30% in the five weeks after its death cross and was 12% higher seven months later. Many traders use it as a filter rather than an entry.

Is the latest SMA 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 SMA for US stocks?

Yes. Use exchange=stocks with a ticker such as TSLA. US stocks are included on the Pro plan and above.

Build with SMA on Binance, Bybit or US stocks. Start for free or browse all 262 indicators.