> ## Documentation Index
> Fetch the complete documentation index at: https://takeprofit.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Indicators quickstart

> Compute your first indicator with the Platform API - pick an indicator from the catalog, read its parameters, compute values over REST, and subscribe to live values over WebSocket.

This guide takes you from an API key to live indicator values in four requests. It assumes you already have a key with the `INDICATOR:ALL:READ` scope and know the `exchange` and `symbol` of a security: the [Platform API quickstart](https://takeprofit.com/docs/platform-api/quickstart.md) covers both.

```bash theme={null}
export TAKEPROFIT_API_KEY="your-api-key"
```

## 1. Pick an indicator

List the built-in indicators. Each entry carries a short `uid`, a longer human-readable `slug` you can use in its place, and the latest published `version`:

```bash theme={null}
curl "https://public-api.takeprofit.com/api/v1/indicators" \
  -H "x-api-key: $TAKEPROFIT_API_KEY"
```

```json theme={null}
{
  "indicators": [
    {
      "uid": "sma",
      "slug": "simple_moving_average",
      "version": 9,
      "title": "Simple Moving Average",
      "shortTitle": "SMA",
      "type": "indicator",
      "kind": "builtIn"
    }
  ]
}
```

## 2. Read its parameters

The indicator details list the parameter IDs the values endpoint accepts as `param.<id>`, with their types, defaults and ranges, and the output IDs that key the computed values:

```bash theme={null}
curl "https://public-api.takeprofit.com/api/v1/indicators/sma" \
  -H "x-api-key: $TAKEPROFIT_API_KEY"
```

```json theme={null}
{
  "uid": "sma",
  "slug": "simple_moving_average",
  "version": 9,
  "title": "Simple Moving Average",
  "overlay": true,
  "params": [
    { "id": "length", "title": "Length", "type": "integer", "default": 9, "min": 1, "max": 1000000, "step": 1 },
    { "id": "src", "title": "Source", "type": "source", "default": "close",
      "options": ["open", "high", "low", "close", "hl2", "hlc3", "ohlc4"] },
    { "id": "offset", "title": "Offset", "type": "integer", "default": 0, "min": -500, "max": 500, "step": 1 }
  ],
  "outputs": [
    { "id": "line_0", "title": "Line 0", "kind": "line" }
  ]
}
```

## 3. Compute values

Ask for the SMA of the 5-minute Binance BTC/USDT candles with a length of 20. Only `exchange`, `symbol`, and `timeframe` are required. Without a range, the endpoint returns the last 1,000 bars — use `limit` to narrow the window:

```bash theme={null}
curl -G "https://public-api.takeprofit.com/api/v1/indicators/sma/values" \
  -H "x-api-key: $TAKEPROFIT_API_KEY" \
  --data-urlencode "exchange=CXBNCE" \
  --data-urlencode "symbol=BTC/USDT" \
  --data-urlencode "timeframe=5m" \
  --data-urlencode "param.length=20" \
  --data-urlencode "limit=3"
```

The response echoes the resolved parameters in `meta.params`, so you can see which defaults filled the gaps, and returns one bar per candle with the values keyed by output ID:

```json theme={null}
{
  "meta": {
    "uid": "sma",
    "slug": "simple_moving_average",
    "version": 9,
    "exchange": "CXBNCE",
    "symbol": "BTC/USDT",
    "timeframe": "5m",
    "params": { "length": 20, "src": "close", "offset": 0 },
    "outputs": ["line_0"]
  },
  "bars": [
    { "timestamp": "2026-10-06T09:50:00Z", "closed": true, "values": { "line_0": 123440.31 } },
    { "timestamp": "2026-10-06T09:55:00Z", "closed": true, "values": { "line_0": 123456.78 } },
    { "timestamp": "2026-10-06T10:00:00Z", "closed": false, "values": { "line_0": 123470.12 } }
  ],
  "hasMoreBefore": true,
  "historyComplete": true
}
```

The last bar has `"closed": false`: it is still forming and its value will change until the bar closes. A bar inside an indicator's warm-up period has no value for that output, and the key is absent from `values` rather than null.

Pin the version for anything that runs unattended (for example, `version=9`). Without it the latest published version runs, and a new version may change the outputs.

## 4. Subscribe to live values

Open a WebSocket connection with the same subscription parameters in the query string and the key in the handshake header. `replay` sets how many latest bars the snapshot carries:

```bash theme={null}
websocat -H "x-api-key: $TAKEPROFIT_API_KEY" \
  "wss://public-api.takeprofit.com/api/v1/indicators/sma/stream?exchange=CXBNCE&symbol=BTC%2FUSDT&timeframe=5m&param.length=20&replay=3"
```

The server sends three kinds of frames and the client sends nothing after the handshake. First comes an `info` frame (the resolved subscription in the same shape as `meta` above), followed by one `snapshot` frame with the last `replay` bars, and then an `update` frame for every change to the forming bar and every new bar:

```json theme={null}
{ "type": "info", "meta": { "uid": "sma", "slug": "simple_moving_average", "version": 9, "exchange": "CXBNCE", "symbol": "BTC/USDT", "timeframe": "5m", "params": { "length": 20, "src": "close", "offset": 0 }, "outputs": ["line_0"] } }
{ "type": "snapshot", "seq": 1, "bars": [ { "timestamp": "2026-10-06T09:50:00Z", "closed": true, "values": { "line_0": 123440.31 } }, { "timestamp": "2026-10-06T09:55:00Z", "closed": true, "values": { "line_0": 123456.78 } }, { "timestamp": "2026-10-06T10:00:00Z", "closed": false, "values": { "line_0": 123470.12 } } ] }
{ "type": "update", "seq": 2, "bar": { "timestamp": "2026-10-06T10:00:00Z", "closed": false, "values": { "line_0": 123471.03 } } }
```

An `update` whose `timestamp` matches an existing bar replaces that bar — update it in place instead of appending. The `seq` field numbers the data frames within a single connection, starting at 1 with the snapshot. After a reconnect the new snapshot replaces whatever you hold; a longer gap is filled from the values endpoint.

A stream that ends with an `error` frame is over, and the socket closes right after it. Reconnect with exponential backoff, waiting at least `retryAfter` seconds when the frame carries it. The frame shapes and the query parameters are on the [Live indicator stream](https://takeprofit.com/docs/platform-api/indicators/stream.md) page.

## Next steps

* The [Indicators API overview](https://takeprofit.com/docs/platform-api/indicators/overview) lists every endpoint, the window parameters, what each request costs, and the error codes.
* Before you scale up, read [Credits and limits](https://takeprofit.com/docs/platform-api/limits.md): indicators spend the same REST and stream quotas as market data.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.