Get coin moving averages

Professional This endpoint requires the professional plan or higher

Get the moving averages for a coin throughout time, in both the simple (SMA) and exponential (EMA) flavours. The supported windows are 20, 50, 100 and 200 periods, and a period is one candle of the interval you request — so interval=day gives the familiar 20/50/100/200-day averages, while interval=hour gives 20/50/100/200-hour ones.

A simple moving average (ma20ma200) weights every candle in its window equally. An exponential moving average (ema20ema200) weights the most recent candles more heavily, so it turns sooner when the price changes direction. Both are expressed in the reference currency, and both become available on the same candle — an EMA is seeded from the simple average of its first window.

The response also carries Bollinger Bands around the 20-period average: bbUpper20 and bbLower20 sit two standard deviations either side of it, so the band widens when the price is volatile and narrows when it settles. There is no middle-band field because a Bollinger middle band is the simple moving average of the same window — it is already published as ma20.

The band is published at two standard deviations, and that is not a limitation. The deviation itself is (bbUpper20 - ma20) / 2, so a band at any other width can be derived from the response without another request.

The window follows the interval rather than always meaning days. A request without an interval uses the default for the chosen timePeriod (see the table below), so pass interval=day explicitly if you want day-denominated averages. Note that interval=day is only available from timePeriod=7d upwards — the shorter periods (1h, 3h, 12h and 24h) do not span enough days to allow it.

https://api.coinranking.com/v2/indicators/:uuid/moving-averages

Path parameters

ParameterDescription
uuid StringUUID of the coin you want to request the moving averages for.

Query parameters

Parameter Description
timePeriod (optional) String

The time period for which the moving average data is returned. The number of data points and the default interval are determined by the time period.

Every time period up to all is available. This endpoint requires the Professional plan, so the Free plan limit that applies to other endpoints does not apply here.

Default value: 24h
Allowed values:
1h 3h 12h 24h 7d 30d 3m 1y 3y 5y 10y all

Example:
https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/moving-averages?timePeriod=7d
interval (optional) String

The interval determines the granularity of each data point. If not provided, a default interval is used based on the selected timePeriod. Only certain intervals are available per timePeriod — see the table below.


timePeriod Available intervals (default in bold)
1hminute, 5minutes
3hminute, 5minutes, hour
12hminute, 5minutes, hour
24hminute, 5minutes, hour, 8hours
7dhour, 8hours, day
30dhour, 8hours, day, week
3mhour, 8hours, day, week, month
1yday, week, month
3yday, week, month
5yday, week, month
10yday, week, month
allday, week, month

Example:
https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/moving-averages?timePeriod=7d&interval=day
referenceCurrencyUuid (optional) String

UUID of coin (either fiat or crypto), in which all the moving average values are calculated. Defaults to US Dollar, but you can use any coin. You can find UUIDs for reference currencies in any coin endpoint, including a convenient dedicated reference currency endpoint

Default value: yhjMzLPhuIDl

Example:
https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/moving-averages?referenceCurrencyUuid=5k-_VTxqtCEI

Code examples

Response

json
HTTP/1.1 200 OK { "status": "success", "data": [ { "startingAt": 1774936800, "ma20": "61051.50263116225", "ma50": "59938.44387892327", "ma100": "67917.84166179039", "ma200": "79262.68876699556", "ema20": "61204.88911204417", "ema50": "60312.77410038255", "ema100": "66984.31220149077", "ema200": "77105.44992018813", "bbUpper20": "62890.11447209318", "bbLower20": "59212.89079023132" }, { "startingAt": 1774933200, "ma20": "61050.102576064244", "ma50": "59937.069348890385", "ma100": "67916.28414532698", "ma200": "79260.87108640283", "ema20": "61203.11764018829", "ema50": "60311.02218804471", "ema100": "66982.90116644302", "ema200": "77103.61884770195", "bbUpper20": "62888.42137705441", "bbLower20": "59211.78377507408" } ] }

Response fields

PropertyDescription
status String

Status of the request

Allowed values:
success
data Object[]

List of moving average data points

data.startingAt Number

An Epoch startingAt in seconds marking the start of the time period.

data.ma20 String/null

The 20-period simple moving average price in the reference currency: the mean closing price over the last 20 candles of the requested interval. null until 20 candles of history exist.

data.ma50 String/null

The 50-period simple moving average price in the reference currency: the mean closing price over the last 50 candles of the requested interval. null until 50 candles of history exist.

data.ma100 String/null

The 100-period simple moving average price in the reference currency: the mean closing price over the last 100 candles of the requested interval. null until 100 candles of history exist.

data.ma200 String/null

The 200-period simple moving average price in the reference currency: the mean closing price over the last 200 candles of the requested interval. null until 200 candles of history exist.

data.ema20 String/null

The 20-period exponential moving average price in the reference currency, over the last 20 candles of the requested interval. Weights recent candles more heavily than ma20, so it responds faster to a change in direction. null until 20 candles of history exist.

data.ema50 String/null

The 50-period exponential moving average price in the reference currency, over the last 50 candles of the requested interval. Weights recent candles more heavily than ma50, so it responds faster to a change in direction. null until 50 candles of history exist.

data.ema100 String/null

The 100-period exponential moving average price in the reference currency, over the last 100 candles of the requested interval. Weights recent candles more heavily than ma100, so it responds faster to a change in direction. null until 100 candles of history exist.

data.ema200 String/null

The 200-period exponential moving average price in the reference currency, over the last 200 candles of the requested interval. Weights recent candles more heavily than ma200, so it responds faster to a change in direction. null until 200 candles of history exist.

data.bbUpper20 String/null

The upper Bollinger Band: ma20 plus two standard deviations of the closing price over the same 20 candles. null until 20 candles of history exist, alongside ma20.

data.bbLower20 String/null

The lower Bollinger Band: ma20 minus the same two standard deviations. The band is centred exactly on ma20, which is why no middle-band field is returned and why the deviation can be recovered as (bbUpper20 - ma20) / 2.

Error response

json
HTTP/1.1 404 Not Found { "status": "fail", "type": "COIN_NOT_FOUND", "message": "Coin not found" }

Error responses