# Ta

Last updated

Last updated

`ta.alma`

**Definition:** Arnaud Legoux Moving Average. It uses Gaussian distribution as weights for moving average.

**Syntax:**

**Returns:** Arnaud Legoux Moving Average.

**Arguments:**

Name | Type | Description |
---|---|---|

`ta.atr`

**Definition:** Function atr (average true range) returns the RMA of true range. True range is max(high - low, abs(high - close[1]), abs(low - close[1])).

**Syntax:**

**Returns:** Average true range.

**Arguments:**

**Example (Pine Script):**

`ta.barssince`

**Definition:** Counts the number of bars since the last time the condition was true.

**Syntax:**

**Returns:** Number of bars since condition was true.

**Arguments:**

**Example (Pine Script):**

`ta.bb`

**Definition:** Bollinger Bands. A Bollinger Band is a technical analysis tool defined by a set of lines plotted two standard deviations (positively and negatively) away from a simple moving average (SMA) of the security's price, but can be adjusted to user preferences.

**Syntax:**

**Returns:** Bollinger Bands.

**Arguments:**

**Example (Pine Script):**

`ta.bbw`

**Definition:** Bollinger Bands Width. The Bollinger Band Width is the difference between the upper and the lower Bollinger Bands divided by the middle band.

**Syntax:**

**Returns:** Bollinger Bands Width.

**Arguments:**

**Example (Pine Script):**

`ta.cci`

**Definition:** The CCI (commodity channel index) is calculated as the difference between the typical price of a commodity and its simple moving average, divided by the mean absolute deviation of the typical price. The index is scaled by an inverse factor of 0.015 to provide more readable numbers.

**Syntax:**

**Returns:** Commodity channel index of source for length bars back.

**Arguments:**

`ta.change`

**Definition:** Compares the current `source`

value to its value `length`

bars ago and returns the difference.

**Syntax:**

**Returns:** The difference between the values when they are numerical. When a 'bool' source is used, returns `true`

when the current source is different from the previous source.

**Arguments:**

**Example (Pine Script):**

`ta.cmo`

**Definition:** Chande Momentum Oscillator. Calculates the difference between the sum of recent gains and the sum of recent losses and then divides the result by the sum of all price movement over the same period.

**Syntax:**

**Returns:** Chande Momentum Oscillator.

**Arguments:**

**Example (Pine Script):**

`ta.cog`

**Definition:** The cog (center of gravity) is an indicator based on statistics and the Fibonacci golden ratio.

**Syntax:**

**Returns:** Center of Gravity.

**Arguments:**

**Example (Pine Script):**

`ta.correlation`

**Definition:** Correlation coefficient. Describes the degree to which two series tend to deviate from their ta.sma values.

**Syntax:**

**Returns:** Correlation coefficient.

**Arguments:**

`ta.cross`

**Definition:** Checks if two series have crossed each other.

**Syntax:**

**Returns:** True if two series have crossed each other, otherwise false.

**Arguments:**

`ta.crossover`

**Definition:** Checks if the `source1`

series has crossed over the `source2`

series.

**Syntax:**

**Returns:** True if `source1`

crossed over `source2`

, otherwise false.

**Arguments:**

`ta.crossunder`

**Definition:** Checks if the `source1`

series has crossed under the `source2`

series.

**Syntax:**

**Returns:** True if `source1`

crossed under `source2`

, otherwise false.

**Arguments:**

`ta.cum`

**Definition:** Cumulative (total) sum of `source`

. In other words, it's the sum of all elements of `source`

.

**Syntax:**

**Returns:** Total sum series.

**Arguments:**

`ta.dev`

**Definition:** Measure of difference between the series and its ta.sma.

**Syntax:**

**Returns:** Deviation of `source`

for `length`

bars back.

**Arguments:**

**Example (Pine Script):**

`ta.dmi`

**Definition:** The dmi function returns the directional movement index.

**Syntax:**

**Returns:** Tuple of three DMI series: Positive Directional Movement (+DI), Negative Directional Movement (-DI), and Average Directional Movement Index (ADX).

**Arguments:**

**Example (Pine Script):**

`ta.ema`

**Definition:** The ema function returns the exponentially weighted moving average. In ema weighting factors decrease exponentially. It calculates by using a formula: EMA = alpha * source + (1 - alpha) * EMA[1], where alpha = 2 / (length + 1).

**Syntax:**

**Returns:** Exponential moving average of `source`

with alpha = 2 / (length + 1).

**Arguments:**

**Example (Pine Script):**

`ta.falling`

**Definition:** Test if the `source`

series is now falling for `length`

bars long.

**Syntax:**

**Returns:** True if the current `source`

value is less than any previous `source`

value for `length`

bars back, false otherwise.

**Arguments:**

`ta.highest`

**Definition:** Highest value for a given number of bars back.

**Syntax:**

**Returns:** Highest value in the series.

**Arguments:**

**Remarks:**

Two args version:

`source`

is a series and`length`

is the number of bars back.One arg version:

`length`

is the number of bars back. Algorithm uses high as a`source`

series.

`ta.highestbars`

**Definition:** Highest value offset for a given number of bars back.

**Syntax:**

**Returns:** Offset to the highest bar.

**Arguments:**

`ta.hma`

**Definition:** The hma function returns the Hull Moving Average.

**Syntax:**

**Returns:** Hull moving average of 'source' for 'length' bars back.

**Arguments:**

`ta.kc`

**Definition:** Keltner Channels. Keltner channel is a technical analysis indicator showing a central moving average line plus channel lines at a distance above and below.

**Syntax:**

**Returns:** Keltner Channels.

**Arguments:**

`ta.kcw`

**Definition:** Keltner Channels Width. The Keltner Channels Width is the difference between the upper and the lower Keltner Channels divided by the middle channel.

**Syntax:**

**Returns:** Keltner Channels Width.

**Arguments:**

`ta.linreg`

**Definition:** Linear regression curve. A line that best fits the prices specified over a user-defined time period. It is calculated using the least squares method.

**Syntax:**

**Returns:** Linear regression curve.

**Arguments:**

`ta.lowest`

**Definition:** Lowest value for a given number of bars back.

**Syntax:**

**Returns:** Lowest value in the series.

**Arguments:**

**Remarks:**

Two args version:

`source`

is a series and`length`

is the number of bars back.One arg version:

`length`

is the number of bars back. Algorithm uses low as a`source`

series.

`ta.lowestbars`

**Definition:** Lowest value offset for a given number of bars back.

**Syntax:**

**Returns:** Offset to the lowest bar.

**Arguments:**

`ta.macd`

**Definition:** Moving average convergence/divergence. It is supposed to reveal changes in the strength, direction, momentum, and duration of a trend in a stock's price.

**Syntax:**

**Returns:** Tuple of three MACD series: MACD line, signal line, and histogram line.

**Arguments:**

`ta.max`

**Definition:** Returns the all-time high value of `source`

from the beginning of the chart up to the current bar.

**Syntax:**

**Returns:** The all-time high value in the series.

**Arguments:**

`ta.median`

**Definition:** Returns the median of the series.

**Syntax:**

**Returns:** The median of the series.

**Arguments:**

`ta.mfi`

**Definition:** Money Flow Index. The Money Flow Index (MFI) is a technical oscillator that uses price and volume for identifying overbought or oversold conditions in an asset.

**Syntax:**

**Returns:** Money Flow Index.

**Arguments:**

`ta.min`

**Definition:** Returns the all-time low value of `source`

from the beginning of the chart up to the current bar.

**Syntax:**

**Returns:** The all-time low value in the series.

**Arguments:**

`ta.mode`

**Definition:** Returns the mode of the series. If there are several values with the same frequency, it returns the smallest value.

**Syntax:**

**Returns:** The most frequently occurring value from the `source`

. If none exists, returns the smallest value instead.

**Arguments:**

`ta.mom`

**Definition:** Momentum of `source`

price and `source`

price `length`

bars ago. This is simply a difference: source - source[length].

**Syntax:**

**Returns:** Momentum of `source`

price and `source`

price `length`

bars ago.

**Arguments:**

`ta.percentile_linear_interpolation`

**Definition:** Calculates percentile using the method of linear interpolation between the two nearest ranks.

**Syntax:**

**Returns:** P-th percentile of `source`

series for `length`

bars back.

**Arguments:**

`ta.percentile_nearest_rank`

**Definition:** Calculates percentile using the method of Nearest Rank.

**Syntax:**

**Returns:** P-th percentile of `source`

series for `length`

bars back.

**Arguments:**

`ta.percentrank`

**Definition:** Percent rank is the percents of how many previous values were less than or equal to the current value of the given series.

**Syntax:**

**Returns:** Percent rank of `source`

for `length`

bars back.

**Arguments:**

`ta.psar`

**Definition:** Parabolic SAR (parabolic stop and reverse) is a method devised by J. Welles Wilder, Jr., to find potential reversals in the market price direction of traded goods.

**Syntax:**

**Returns:** Parabolic SAR.

**Arguments:**

`ta.pvt`

**Definition:** Price-volume trend indicator (PVT) shows the relationship between price and volume and is designed to confirm price trends.

**Syntax:**

**Returns:** Price-volume trend indicator.

**Arguments:**

`ta.rma`

**Definition:** Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length.

**Syntax:**

**Returns:** Exponential moving average of `source`

with alpha = 1 / `length`

.

**Arguments:**

`ta.roc`

**Definition:** Calculates the percentage of change (rate of change) between the current value of `source`

and its value `length`

bars ago.

**Syntax:**

**Returns:** The rate of change of `source`

for `length`

bars back.

**Arguments:**

`ta.rsi`

**Definition:** Relative strength index. It is calculated using the `ta.rma()`

of upward and downward changes of `source`

over the last `length`

bars.

**Syntax:**

**Returns:** Relative strength index.

**Arguments:**

`ta.sar`

**Definition:** Parabolic SAR (parabolic stop and reverse) is a method devised by J. Welles Wilder, Jr., to find potential reversals in the market price direction of traded goods.

**Syntax:**

**Returns:** Parabolic SAR.

**Arguments:**

`ta.sma`

**Definition:** The sma function returns the moving average, that is the sum of the last `length`

values of `source`

, divided by `length`

.

**Syntax:**

**Returns:** Simple moving average of `source`

for `length`

bars back.

**Arguments:**

`ta.stdev`

**Definition:** Standard deviation.

**Syntax:**

**Returns:** Standard deviation.

**Arguments:**

`ta.stoch`

**Definition:** Stochastic. It is calculated by a formula: 100 * (close - lowest(low, length)) / (highest(high, length) - lowest(low, length)).

**Syntax:**

**Returns:** Stochastic.

**Arguments:**

`ta.supertrend`

**Definition:** The Supertrend Indicator. The Supertrend is a trend following indicator.

**Syntax:**

**Returns:** Tuple of two supertrend series: supertrend line and direction of trend. Possible values are 1 (down direction) and -1 (up direction).

**Arguments:**

`ta.swma`

**Definition:** Symmetrically weighted moving average with fixed length: 4. Weights: [1/6, 2/6, 2/6, 1/6].

**Syntax:**

**Returns:** Symmetrically weighted moving average.

**Arguments:**

`ta.tr`

**Definition:** True range. It is `math.max(high - low, math.abs(high - close[1]), math.abs(low - close[1])`

.

**Syntax:**

**Returns:** True range.

**Arguments:**

`ta.tsi`

**Definition:** True strength index. It uses moving averages of the underlying momentum of a financial instrument.

**Syntax:**

**Returns:** True strength index. A value in the range [-1, 1].

**Arguments:**

`ta.valuewhen`

**Definition:** Returns the value of the `source`

series on the bar where the `condition`

was true on the nth most recent occurrence.

**Syntax:**