Ta
ta.alma
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 |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
| simple int/float | Controls tradeoff between smoothness (closer to 1) and responsiveness (closer to 0). |
| simple int/float | Changes the smoothness of ALMA. The larger sigma, the smoother ALMA. |
| simple bool (optional) | An optional parameter. Specifies whether the offset calculation is floored before ALMA is calculated. Default value is false. |
ta.atr
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:
Name | Type | Description |
---|---|---|
| simple int | Length (number of bars back). |
Example (Pine Script):
ta.barssince
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:
Name | Type | Description |
---|---|---|
| condition | The condition to check. |
Example (Pine Script):
ta.bb
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
| simple int/float | Standard deviation factor. |
Example (Pine Script):
ta.bbw
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
| simple int/float | Standard deviation factor. |
Example (Pine Script):
ta.cci
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
ta.change
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:
Name | Type | Description |
---|---|---|
| series int/float/bool | Source series. |
| series int (optional) | How far the past |
Example (Pine Script):
ta.cmo
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
Example (Pine Script):
ta.cog
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
Example (Pine Script):
ta.correlation
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:
Name | Type | Description |
---|---|---|
| series int/float | Source series. |
| series int/float | Target series. |
| series int | Length (number of bars back). |
ta.cross
ta.cross
Definition: Checks if two series have crossed each other.
Syntax:
Returns: True if two series have crossed each other, otherwise false.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | First data series. |
| series int/float | Second data series. |
ta.crossover
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:
Name | Type | Description |
---|---|---|
| series int/float | First data series. |
| series int/float | Second data series. |
ta.crossunder
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:
Name | Type | Description |
---|---|---|
| series int/float | First data series. |
| series int/float | Second data series. |
ta.cum
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:
Name | Type | Description |
---|---|---|
| series int/float | Source used for the calculation. |
ta.dev
ta.dev
Definition: Measure of difference between the series and its ta.sma.
Syntax:
Returns: Deviation of source
for length
bars back.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
Example (Pine Script):
ta.dmi
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:
Name | Type | Description |
---|---|---|
| simple int | DI Period. |
| simple int | ADX Smoothing Period. |
Example (Pine Script):
ta.ema
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| simple int | Number of bars (length). |
Example (Pine Script):
ta.falling
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
ta.highest
ta.highest
Definition: Highest value for a given number of bars back.
Syntax:
Returns: Highest value in the series.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
Remarks:
Two args version:
source
is a series andlength
is the number of bars back.One arg version:
length
is the number of bars back. Algorithm uses high as asource
series.
ta.highestbars
ta.highestbars
Definition: Highest value offset for a given number of bars back.
Syntax:
Returns: Offset to the highest bar.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
ta.hma
ta.hma
Definition: The hma function returns the Hull Moving Average.
Syntax:
Returns: Hull moving average of 'source' for 'length' bars back.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| simple int | Number of bars. |
ta.kc
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
| series int/float | Standard deviation factor. |
| series bool | An optional parameter. Specifies if True Range is used; default is true. If the value is false, the range will be calculated with the expression (high - low). |
ta.kcw
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| simple int | Number of bars (length). |
| simple int/float | Standard deviation factor. |
| simple bool | An optional parameter. Specifies if True Range is used; default is true. If the value is false, the range will be calculated with the expression (high - low). |
ta.linreg
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:
Name | Type | Description |
---|---|---|
| series int/float | Source series. |
| series int | Number of bars (length). |
| simple int | Offset. |
ta.lowest
ta.lowest
Definition: Lowest value for a given number of bars back.
Syntax:
Returns: Lowest value in the series.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
Remarks:
Two args version:
source
is a series andlength
is the number of bars back.One arg version:
length
is the number of bars back. Algorithm uses low as asource
series.
ta.lowestbars
ta.lowestbars
Definition: Lowest value offset for a given number of bars back.
Syntax:
Returns: Offset to the lowest bar.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
ta.macd
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| simple int | Fast Length parameter. |
| simple int | Slow Length parameter. |
| simple int | Signal Length parameter. |
ta.max
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:
Name | Type | Description |
---|---|---|
| series int/float | Source used for the calculation. |
ta.median
ta.median
Definition: Returns the median of the series.
Syntax:
Returns: The median of the series.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
ta.mfi
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
ta.min
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:
Name | Type | Description |
---|---|---|
| series int/float | Source used for the calculation. |
ta.mode
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
ta.mom
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Offset from the current bar to the previous bar. |
ta.percentile_linear_interpolation
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process (source). |
| series int | Number of bars back (length). |
| simple int/float | Percentage, a number from the range 0..100. |
ta.percentile_nearest_rank
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process (source). |
| series int | Number of bars back (length). |
| simple int/float | Percentage, a number from the range 0..100. |
ta.percentrank
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars back (length). |
ta.psar
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:
Name | Type | Description |
---|---|---|
| simple int/float | Start. |
| simple int/float | Increment. |
| simple int/float | Maximum. |
ta.pvt
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:
Name | Type | Description |
---|---|---|
| series int/float | Close price series. |
| series int/float | Volume series. |
ta.rma
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| simple int | Number of bars (length). |
ta.roc
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
ta.rsi
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| simple int | Number of bars (length). |
ta.sar
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:
Name | Type | Description |
---|---|---|
| simple int/float | Start. |
| simple int/float | Increment. |
| simple int/float | Maximum. |
ta.sma
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:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
ta.stdev
ta.stdev
Definition: Standard deviation.
Syntax:
Returns: Standard deviation.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
| series bool | Determines which estimate should be used. Optional. The default is true. |
ta.stoch
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:
Name | Type | Description |
---|---|---|
| series int/float | Source series. |
| series int/float | Series of high. |
| series int/float | Series of low. |
| series int | Length (number of bars back). |
ta.supertrend
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:
Name | Type | Description |
---|---|---|
| series int/float | The multiplier by which the ATR will get multiplied. |
| simple int | Length of ATR. |
ta.swma
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:
Name | Type | Description |
---|---|---|
| series int/float | Source series. |
ta.tr
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:
Name | Type | Description |
---|---|---|
| simple bool | How NaN values are handled. If true, and the previous day's close is NaN, then |
ta.tsi
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:
Name | Type | Description |
---|---|---|
| series int/float | Source series. |
| simple int | Short length. |
| simple int | Long length. |
ta.valuewhen
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:
Returns: The value of the source
series on the bar where the condition
was true on the nth most recent occurrence.
Arguments:
Name | Type | Description |
---|---|---|
| series bool | The condition to search for. |
| series int/float/bool/color | The value to be returned from the bar where the condition is met. |
| simple int | The occurrence of the condition. The numbering starts from 0 and goes back in time, so '0' is the most recent occurrence of |
ta.variance
ta.variance
Definition: Variance is the expectation of the squared deviation of a series from its mean (ta.sma
), and it informally measures how far a set of numbers are spread out from their mean.
Syntax:
Returns: Variance of source
for length
bars back.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
| series bool | Determines which estimate should be used. Optional. The default is true. |
ta.vwap
ta.vwap
Definition: Volume weighted average price.
Syntax:
Returns: A VWAP series or a tuple [vwap, upper_band, lower_band] if stdev_mult
is specified.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Source used for the VWAP calculation. |
| series bool | The condition that triggers the reset of VWAP calculations. When true, calculations reset; when false, calculations proceed using the values accumulated since the previous reset. Optional. The default is equivalent to passing |
| series int/float | If specified, the function will calculate the standard deviation bands based on the main VWAP series and return a [vwap, upper_band, lower_band] tuple. The |
ta.vwma
ta.vwma
Definition: The vwma function returns volume-weighted moving average of source
for length
bars back. It is the same as: sma(source * volume, length) / sma(volume, length)
.
Syntax:
Returns: Volume-weighted moving average of source
for length
bars back.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
ta.wma
ta.wma
Definition: The wma function returns weighted moving average of source
for length
bars back. In wma, weighting factors decrease in arithmetical progression.
Syntax:
Returns: Weighted moving average of source
for length
bars back.
Arguments:
Name | Type | Description |
---|---|---|
| series int/float | Series of values to process. |
| series int | Number of bars (length). |
ta.wpr
ta.wpr
Definition: Williams %R. The oscillator shows the current closing price in relation to the high and low of the past 'length' bars.
Syntax:
Returns: Williams %R.
Arguments:
Name | Type | Description |
---|---|---|
| series int | Number of bars. |
Last updated