How to Calculate SMA, EMA, RSI, and MACD Using the Mboum Indicators API

Technical indicators are the building blocks of algorithmic trading strategies, providing the quantitative data necessary to analyze market trends, momentum, and volatility. While it is possible to calculate these indicators manually using historical price data, doing so requires maintaining large datasets and performing resource-intensive computations on the client side.

The Mboum API allows developers to offload these calculations, retrieving pre-computed technical analysis data directly via dedicated endpoints. This ensures that trading bots and financial dashboards remain lightweight and responsive.

👉 You can obtain your API key and begin integrating these indicators by visiting the dashboard here: https://mboum.com/pages/api


The Indicators Endpoints

Mboum provides specific endpoints for the most common technical indicators. To integrate these into your application, you will primarily interact with the Technical Indicator section of the API.

Common Parameters

When constructing requests for these endpoints, several parameters ensure accurate analysis:

  • ticker – The symbol of the asset to analyze (e.g., AAPL, BTC-USD)

  • interval – The time interval between data points. Supported values include 1m, 5m, 15m, 30m, 1h, 1d, 1wk, 1mo, and 3mo

  • series_type – The specific price point used for calculation. Common values are close, open, high, and low

  • limit – How many of the latest values to return (1 to 1000, default 50)

Indicator-Specific Parameters

Certain indicators require unique inputs to define their sensitivity:

  • For SMA, EMA, and RSI, you must define the time_period (e.g., 14 for standard RSI or 50 for a moving average)

  • For MACD, you must define the fast_period, slow_period, and signal_period (standard defaults are often 12, 26, and 9 respectively)


Python Example

The following Python script demonstrates how to fetch RSI, SMA, and MACD data for Apple (AAPL) using the requests library. This example requests a 50-day SMA, a standard 14-period RSI, and standard MACD settings on a daily interval.

import requests
import json

# Configuration
base_url = "https://api.mboum.com/v1/markets/indicators"
auth_header = {
    'Authorization': 'Bearer {YOUR_AUTH_KEY}'
}

def get_indicator(indicator_type, params):
    endpoint = f"{base_url}/{indicator_type}"
    try:
        response = requests.get(endpoint, headers=auth_header, params=params)
        response.raise_for_status()
        return response.json()
    except requests.exceptions.RequestException as e:
        print(f"Error fetching {indicator_type}: {e}")
        return None

# 1. Fetch SMA (50-period)
sma_params = {
    'ticker': 'AAPL',
    'interval': '1d',
    'series_type': 'close',
    'time_period': '50',
    'limit': '1'  # Get only the most recent value
}
sma_data = get_indicator("sma", sma_params)

# 2. Fetch RSI (14-period)
rsi_params = {
    'ticker': 'AAPL',
    'interval': '1d',
    'series_type': 'close',
    'time_period': '14',
    'limit': '1'
}
rsi_data = get_indicator("rsi", rsi_params)

# 3. Fetch MACD (12, 26, 9)
macd_params = {
    'ticker': 'AAPL',
    'interval': '1d',
    'series_type': 'close',
    'fast_period': '12',
    'slow_period': '26',
    'signal_period': '9',
    'limit': '1'
}
macd_data = get_indicator("macd", macd_params)

def latest_item(data):
    """body is a list of {"timestamp": ..., "<INDICATOR>": value}, oldest first."""
    if not data or data.get("success") is False or not data.get("body"):
        return {}
    return data["body"][-1]

# Output results
sma = latest_item(sma_data)
rsi = latest_item(rsi_data)
macd = latest_item(macd_data)

print("Technical Analysis for AAPL (Daily):")
print(f"SMA (50): {sma.get('SMA')}")
print(f"RSI (14): {rsi.get('RSI')}")
print(f"MACD: {macd.get('MACD')} | Signal: {macd.get('MACD_Signal')} | Histogram: {macd.get('MACD_Hist')}")

Understanding the Response

Every indicator endpoint returns a meta object that echoes your request and a body list. Each item in body holds a Unix timestamp in seconds plus the value or values, keyed by the indicator name. The list runs from oldest to newest, so the last item is the latest, and limit=1 returns only that item. When parsing the response, it is critical to map the values correctly to your trading logic.

SMA / EMA / RSI Response Structure

The value sits under a key named after the indicator: SMA, EMA or RSI. This is a real SMA response for AAPL, with meta trimmed:

{
  "meta": { "symbol": "AAPL", "interval": "1d", "time_period": "50" },
  "body": [
    { "timestamp": 1795530600, "SMA": 342.582 }
  ]
}

MACD Response Structure

{
  "meta": { "symbol": "AAPL", "interval": "1d", "fast_period": "12", "slow_period": "26", "signal_period": "9" },
  "body": [
    {
      "timestamp": 1795530600,
      "MACD": 2.697,
      "MACD_Signal": 3.133,
      "MACD_Hist": -0.435
    }
  ]
}

Field Meanings

  • timestamp – Unix time in seconds that identifies the candle (for 1d candles it is 9:30 AM Eastern on that trading day)

  • SMA, EMA, RSI – The calculated indicator value, under a key named after the indicator

  • MACD – The difference between the fast and slow moving averages

  • MACD_Signal – The moving average of the MACD line itself

  • MACD_Hist – The difference between the MACD and the signal line (often displayed as a histogram)

If there is no data to return, the API answers with HTTP 200 and "success": false plus a message, and invalid parameters return HTTP 422. The example script prints None for a value in that case.

Running the script on November 24, 2026 printed:

Technical Analysis for AAPL (Daily):
SMA (50): 342.582
RSI (14): 56.709
MACD: 2.697 | Signal: 3.133 | Histogram: -0.435

Practical Use Cases

By retrieving these indicators programmatically, developers can automate complex trading signals:

Trend Confirmation (Golden Cross)

A common strategy involves monitoring the intersection of short-term and long-term moving averages. By fetching both the 50-day SMA and the 200-day SMA via the SMA endpoint, an algorithm can automatically detect a Golden Cross when the SMA 50 crosses above the SMA 200, signaling a potential bullish trend.

https://docs.mboum.com#stocks-options-GETapi-v1-markets-indicators-sma

Overbought / Oversold Alerts

Using the RSI endpoint, an application can monitor a watchlist of assets. If the API returns an RSI value greater than 70, the system can flag the asset as overbought. Conversely, a value below 30 can trigger an oversold alert, indicating a potential buying opportunity.

https://docs.mboum.com#stocks-options-GETapi-v1-markets-indicators-rsi

The Mboum Indicators API provides a streamlined method for accessing essential technical analysis data without the overhead of local computation. By utilizing endpoints for SMA, EMA, RSI, and MACD, developers can build robust, data-driven financial applications that respond to market movements in real time.

👉 Start building your analysis tools today by generating your key at: https://mboum.com/pages/api