GitHubBlog

Search Documentation

Search for a page in the docs

Technical Analysis

The calculateIndicator tool lets you compute technical indicators using an Excel-like formula syntax. It works across equities, crypto, and currencies with the same syntax.

Basic Usage

You: What's the 50-day moving average of AAPL?

Alice: [calls calculateIndicator(asset="equity", formula="SMA(CLOSE('AAPL', '1d'), 50)")]
       AAPL 50-day SMA: $189.42

The asset parameter determines which data source to use:

  • equity — Stocks (e.g. AAPL, MSFT, NVDA)
  • crypto — Cryptocurrencies (e.g. BTCUSD, ETHUSD)
  • currency — Forex pairs (e.g. EURUSD, GBPUSD)

Formula Syntax

Data Access Functions

FunctionDescription
CLOSE(symbol, interval)Closing prices
OPEN(symbol, interval)Opening prices
HIGH(symbol, interval)High prices
LOW(symbol, interval)Low prices
VOLUME(symbol, interval)Volume data

Intervals: 1d (daily), 1w (weekly), 1h (hourly), 5m (5-minute), etc.

Statistical Functions

FunctionDescription
SMA(data, period)Simple Moving Average
EMA(data, period)Exponential Moving Average
STDEV(data, period)Standard Deviation
MAX(data, period)Rolling Maximum
MIN(data, period)Rolling Minimum
SUM(data, period)Rolling Sum
AVERAGE(data, period)Rolling Average

Technical Indicators

FunctionDescription
RSI(data, period)Relative Strength Index
BBANDS(data, period, stddev)Bollinger Bands (returns upper, middle, lower)
MACD(data, fast, slow, signal)MACD (returns macd, signal, histogram)
ATR(highs, lows, closes, period)Average True Range

Array Access

Use bracket notation to get specific values:

CLOSE('AAPL', '1d')[-1]     // Most recent close
CLOSE('AAPL', '1d')[-2]     // Previous close
SMA(CLOSE('AAPL', '1d'), 50)[-1]  // Latest 50-day SMA value

Operators

Formulas support arithmetic: +, -, *, /

CLOSE('AAPL', '1d')[-1] / SMA(CLOSE('AAPL', '1d'), 200)[-1]

Examples

Moving average crossover check:

SMA(CLOSE('AAPL', '1d'), 50)
SMA(CLOSE('AAPL', '1d'), 200)

RSI overbought/oversold:

RSI(CLOSE('NVDA', '1d'), 14)

Bollinger Bands:

BBANDS(CLOSE('AAPL', '1d'), 20, 2)

MACD:

MACD(CLOSE('AAPL', '1d'), 12, 26, 9)

Crypto RSI on hourly chart:

RSI(CLOSE('BTCUSD', '1h'), 14)

ATR for volatility:

ATR(HIGH('AAPL', '1d'), LOW('AAPL', '1d'), CLOSE('AAPL', '1d'), 14)

Data Ranges

Historical OHLCV data is fetched automatically based on the interval:

IntervalData Range
Minutes (5m, 15m)~30 days
Hourly (1h)~90 days
Daily (1d)~2 years
Weekly (1w)~5 years

Precision

Results default to 4 decimal places. Use the precision parameter to adjust:

calculateIndicator(asset="equity", formula="RSI(CLOSE('AAPL', '1d'), 14)", precision=2)