Indicators

This section documents the indicator (ta.*) functions.


ta.sma

Simple Moving Average. Calculates the average price over a specified period.

Syntax:

ta.sma(symbol, period)
ta.sma(data_series, period)  // Custom data series

Parameters:

  • symbol or data_series: Input series or symbol (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 20)

Examples:

// Default SMA
ta.sma($BTC)  // Same as ta.sma($BTC, 20)

// SMA crossover
ta.crossover(ta.sma($BTC, 10), ta.sma($BTC, 50))

// Custom data series SMA
ta.sma($BTC.volume, 10)

// Historical access
ta.sma($BTC, 20)[1]  // Previous SMA value

Returns: Array of SMA values with historical access


ta.ema

Exponential Moving Average. Gives more weight to recent prices.

Syntax:

Parameters:

  • symbol or data_series: Input series or symbol (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 20)

Examples:

Returns: Array of EMA values with historical access


ta.wma

Weighted Moving Average. Linear weighting with recent prices having more weight.

Syntax:

Parameters:

  • symbol or data_series: Input series or symbol (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 20)

Examples:

Returns: Array of WMA values with historical access


ta.wema

Wilder's Smoothed Moving Average. Used in RSI and other Wilder indicators.

Syntax:

Parameters:

  • symbol or data_series: Input series or symbol (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 20)

Examples:

Returns: Array of WEMA values with historical access


ta.trix

Triple Exponentially Smoothed Moving Average. Provides heavily smoothed trend direction with minimal lag.

Syntax:

Parameters:

  • symbol or data_series: Input series or symbol (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 20)

Examples:

Returns: Array of TRIX values with historical access


ta.rsi

Relative Strength Index. Measures overbought/oversold conditions.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 14)

Examples:

Returns: Array of RSI values (0-100) with historical access


ta.macd

Moving Average Convergence Divergence. Shows relationship between two moving averages.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • fast: Fast EMA period (default 12)

  • slow: Slow EMA period (default 26)

  • signal: Signal line EMA period (default 9)

Examples:

Returns: MACD line value by default, or object with MACD, signal, and histogram properties when accessing subproperties


ta.stoch

Stochastic Oscillator. Compares closing price to price range over time.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • kPeriod: %K period (default 14)

  • dPeriod: %D smoothing period (default 3)

Examples:

Returns: %K line value by default, or object with k and d properties when accessing subproperties


ta.stochrsi

Stochastic RSI. Applies Stochastic oscillator to RSI values.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • kPeriod: %K period (default 3)

  • dPeriod: %D smoothing period (default 3)

  • rsiPeriod: Underlying RSI period (default 14)

  • stochPeriod: Stochastic lookback for RSI (default 14)

Examples:

Returns: StochRSI value by default, or object with stochRSI, k and d properties (0-1 range) when accessing subproperties


ta.cci

Commodity Channel Index. Measures deviation from statistical mean.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 20)

Examples:

Returns: Array of CCI values with historical access


ta.adx

Average Directional Index. Measures trend strength.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 14)

Examples:

Returns: ADX value by default, or object with adx, pdi, and mdi properties when accessing subproperties


ta.psar

Parabolic SAR. Trend-following indicator that provides stop and reverse points.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • step: Acceleration factor increment per new extreme point (e.g., 0.02)

  • max: Maximum acceleration factor cap (e.g., 0.2)

Examples:

Returns: Array of PSAR values with historical access


ta.atr

Average True Range. Measures market volatility.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 14)

Examples:

Returns: Array of ATR values with historical access


ta.bb

Bollinger Bands. Shows dynamic support and resistance levels.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • period: SMA period for middle band (default 20)

  • stdDev: Standard deviation multiplier (default 2)

Examples:

Returns: Middle band value by default, or object with upper, middle, lower, and pb properties when accessing subproperties


ta.vwap

Volume Weighted Average Price. Average price weighted by volume.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

Examples:

Returns: Array of VWAP values with historical access


ta.obv

On-Balance Volume. Relates volume to price change.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

Examples:

Returns: Array of OBV values with historical access


ta.mfi

Money Flow Index. Volume-weighted RSI.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 14)

Examples:

Returns: Array of MFI values (0-100) with historical access


ta.adl

Accumulation Distribution Line. Measures volume flow.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

Examples:

Returns: Array of ADL values with historical access


ta.fi

Force Index. Combines price and volume to assess buying/selling pressure.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 1)

Examples:

Returns: Array of Force Index values with historical access


ta.roc

Rate of Change. Measures percentage change over time.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 12)

Examples:

Returns: Array of ROC values (percentage) with historical access


ta.ao

Awesome Oscillator. Momentum indicator comparing recent momentum to longer-term momentum.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

Examples:

Returns: Array of Awesome Oscillator values with historical access


ta.williamsr

Williams %R. Momentum oscillator measuring overbought/oversold levels.

Syntax:

Parameters:

  • symbol: The symbol to analyze (e.g., '$BTC', '$ETH')

  • period: Lookback window length (default 14)

Examples:

Returns: Array of Williams %R values (-100 to 0) with historical access


ta.pivothigh

Identifies pivot high points where price is higher than surrounding bars on both sides.

Syntax:

Parameters:

  • symbol or data_series: Input series or symbol (e.g., '$BTC', '$ETH')

  • leftbars: Number of bars to the left that must be lower than the pivot bar

  • rightbars: Number of bars to the right that must be lower than the pivot bar

Examples:

Returns: Array of confirmed pivot high values with historical access; null otherwise.


ta.pivotlow

Identifies pivot low points where price is lower than surrounding bars on both sides.

Syntax:

Parameters:

  • symbol or data_series: Input series or symbol (e.g., '$BTC', '$ETH')

  • leftbars: Number of bars to the left that must be higher than the pivot bar

  • rightbars: Number of bars to the right that must be higher than the pivot bar

Examples:

Returns: Array of confirmed pivot low values with historical access; null otherwise.

Last updated

Was this helpful?