ta — Library by TradingView (2024)

Library "ta"

█ OVERVIEW

This library holds technical ​analysis functions calculating values for which no Pine built-in exists.

Look first. Then leap.

█ FUNCTIONS

cagr(entryTime, entryPrice, exitTime, exitPrice)
It calculates the "Compound Annual Growth Rate" between two points in time. The ​CAGR is a notional, annualized growth rate that assumes all profits are reinvested. It only takes into account the prices of the two end points — not drawdowns, so it does not calculate risk. It can be used as a yardstick to compare the performance of two instruments. Because it annualizes values, the function requires a minimum of one day between the two end points (annualizing returns over smaller periods of times doesn't produce very meaningful figures).
  Parameters:
    entryTime: The starting timestamp.
    entryPrice: The starting point's price.
    exitTime: The ending timestamp.
    exitPrice: The ending point's price.
  Returns: ​CAGR in % (50 is 50%). Returns `na` if there is not >=1D between `entryTime` and `exitTime`, or until the two time points have not been reached by the script.

█ v2, Mar. 8, 2022

Added functions `allTimeHigh()` and `allTimeLow()` to find the highest or lowest value of a source from the first historical bar to the current bar. These functions will not look ahead; they will only return new highs/lows on the bar where they occur.

allTimeHigh(​src)
Tracks the highest value of `src` from the first historical bar to the current bar.
  Parameters:
    src: (series int/float) Series to track. Optional. The default is `high`.
  Returns: (float) The highest value tracked.

allTimeLow(​src)
Tracks the lowest value of `src` from the first historical bar to the current bar.
  Parameters:
    src: (series int/float) Series to track. Optional. The default is `low`.
  Returns: (float) The lowest value tracked.

█ v3, Sept. 27, 2022

This version includes the following new functions:

aroon(length)
  Calculates the values of the Aroon indicator.
  Parameters:
    length (simple int): (simple int) Number of bars (length).
  Returns: ([float, float]) A tuple of the Aroon-Up and Aroon-Down values.

coppock(source, longLength, shortLength, smoothLength)
  Calculates the value of the Coppock Curve indicator.
  Parameters:
    source (float): (series int/float) Series of values to process.
    longLength (simple int): (simple int) Number of bars for the fast ROC value (length).
    shortLength (simple int): (simple int) Number of bars for the slow ROC value (length).
    smoothLength (simple int): (simple int) Number of bars for the weigted moving average value (length).
  Returns: (float) The oscillator value.

dema(source, length)
  Calculates the value of the Double Exponential Moving Average (DEMA).
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (simple int): (simple int) Length for the smoothing parameter calculation.
  Returns: (float) The double exponentially weighted moving average of the `source`.

d​ema2(​src, length)
  An alternate ​Double Exponential ​Moving Average (D​ema) function to `d​ema()`, which allows a "series float" length argument.
  Parameters:
    ​src: (series int/float) Series of values to process.
    length: (series int/float) Length for the smoothing parameter calculation.
  Returns: (float) The double exponentially ​weighted moving average of the `​src`.

dm(length)
  Calculates the value of the "Demarker" indicator.
  Parameters:
    length (simple int): (simple int) Number of bars (length).
  Returns: (float) The oscillator value.

donchian(length)
  Calculates the values of a Donchian Channel using `high` and `low` over a given `length`.
  Parameters:
    length (int): (series int) Number of bars (length).
  Returns: ([float, float, float]) A tuple containing the channel high, low, and median, respectively.

​ema2(​src, length)
  An alternate ​ema function to the `ta.​ema()` built-in, which allows a "series float" length argument.
  Parameters:
    ​src: (series int/float) Series of values to process.
    length: (series int/float) Number of bars (length).
  Returns: (float) The exponentially ​weighted moving average of the `​src`.

eom(length, div)
  Calculates the value of the Ease of Movement indicator.
  Parameters:
    length (simple int): (simple int) Number of bars (length).
    div (simple int): (simple int) Divisor used for normalzing values. Optional. The default is 10000.
  Returns: (float) The oscillator value.

frama(source, length)
  The Fractal Adaptive Moving Average (FRAMA), developed by John Ehlers, is an adaptive moving average that dynamically adjusts its lookback period based on fractal geometry.
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (int): (series int) Number of bars (length).
  Returns: (float) The fractal adaptive moving average of the `source`.

ft(source, length)
  Calculates the value of the Fisher Transform indicator.
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (simple int): (simple int) Number of bars (length).
  Returns: (float) The oscillator value.

ht(source)
  Calculates the value of the Hilbert Transform indicator.
  Parameters:
    source (float): (series int/float) Series of values to process.
  Returns: (float) The oscillator value.

ichimoku(conLength, baseLength, senkouLength)
  Calculates values of the Ichimoku Cloud indicator, including tenkan, kijun, senkouSpan1, senkouSpan2, and chikou. NOTE: offsets forward or backward can be done using the `offset` argument in `plot()`.
  Parameters:
    conLength (int): (series int) Length for the Conversion Line (Tenkan). The default is 9 periods, which returns the mid-point of the 9 period Donchian Channel.
    baseLength (int): (series int) Length for the Base Line (Kijun-sen). The default is 26 periods, which returns the mid-point of the 26 period Donchian Channel.
    senkouLength (int): (series int) Length for the Senkou Span 2 (Leading Span B). The default is 52 periods, which returns the mid-point of the 52 period Donchian Channel.
  Returns: ([float, float, float, float, float]) A tuple of the Tenkan, Kijun, Senkou Span 1, Senkou Span 2, and Chikou Span values. NOTE: by default, the senkouSpan1 and senkouSpan2 should be plotted 26 periods in the future, and the Chikou Span plotted 26 days in the past.

ift(source)
  Calculates the value of the Inverse Fisher Transform indicator.
  Parameters:
    source (float): (series int/float) Series of values to process.
  Returns: (float) The oscillator value.

kvo(fastLen, slowLen, trigLen)
  Calculates the values of the Klinger Volume Oscillator.
  Parameters:
    fastLen (simple int): (simple int) Length for the fast moving average smoothing parameter calculation.
    slowLen (simple int): (simple int) Length for the slow moving average smoothing parameter calculation.
    trigLen (simple int): (simple int) Length for the trigger moving average smoothing parameter calculation.
  Returns: ([float, float]) A tuple of the KVO value, and the trigger value.

pzo(length)
  Calculates the value of the Price Zone Oscillator.
  Parameters:
    length (simple int): (simple int) Length for the smoothing parameter calculation.
  Returns: (float) The oscillator value.

rms(source, length)
  Calculates the Root Mean Square of the `source` over the `length`.
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (int): (series int) Number of bars (length).
  Returns: (float) The RMS value.

rwi(length)
  Calculates the values of the Random Walk Index.
  Parameters:
    length (simple int): (simple int) Lookback and ATR smoothing parameter length.
  Returns: ([float, float]) A tuple of the `rwiHigh` and `rwiLow` values.

stc(source, fast, slow, cycle, d1, d2)
  Calculates the value of the Schaff Trend Cycle indicator.
  Parameters:
    source (float): (series int/float) Series of values to process.
    fast (simple int): (simple int) Length for the MACD fast smoothing parameter calculation.
    slow (simple int): (simple int) Length for the MACD slow smoothing parameter calculation.
    cycle (simple int): (simple int) Number of bars for the Stochastic values (length).
    d1 (simple int): (simple int) Length for the initial %D smoothing parameter calculation.
    d2 (simple int): (simple int) Length for the final %D smoothing parameter calculation.
  Returns: (float) The oscillator value.

stochFull(periodK, smoothK, periodD)
  Calculates the %K and %D values of the Full Stochastic indicator.
  Parameters:
    periodK (simple int): (simple int) Number of bars for Stochastic calculation. (length).
    smoothK (simple int): (simple int) Number of bars for smoothing of the %K value (length).
    periodD (simple int): (simple int) Number of bars for smoothing of the %D value (length).
  Returns: ([float, float]) A tuple of the slow %K and the %D moving average values.

stochRsi(lengthRsi, periodK, smoothK, periodD, source)
  Calculates the %K and %D values of the Stochastic RSI indicator.
  Parameters:
    lengthRsi (simple int): (simple int) Length for the RSI smoothing parameter calculation.
    periodK (simple int): (simple int) Number of bars for Stochastic calculation. (length).
    smoothK (simple int): (simple int) Number of bars for smoothing of the %K value (length).
    periodD (simple int): (simple int) Number of bars for smoothing of the %D value (length).
    source (float): (series int/float) Series of values to process. Optional. The default is `close`.
  Returns: ([float, float]) A tuple of the slow %K and the %D moving average values.

supertrend(factor, atrLength, wicks)
  Calculates the values of the SuperTrend indicator with the ability to take candle wicks into account, rather than only the closing price.
  Parameters:
    factor (float): (series int/float) Multiplier for the ATR value.
    atrLength (simple int): (simple int) Length for the ATR smoothing parameter calculation.
    wicks (simple bool): (simple bool) Condition to determine whether to take candle wicks into account when reversing trend, or to use the close price. Optional. Default is false.
  Returns: ([float, int]) A tuple of the superTrend value and trend direction.

szo(source, length)
  Calculates the value of the Sentiment Zone Oscillator.
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (simple int): (simple int) Length for the smoothing parameter calculation.
  Returns: (float) The oscillator value.

t3(source, length, vf)
  Calculates the value of the Tilson Moving Average (T3).
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (simple int): (simple int) Length for the smoothing parameter calculation.
    vf (simple float): (simple float) Volume factor. Affects the responsiveness.
  Returns: (float) The Tilson moving average of the `source`.

t3Alt(source, length, vf)
  An alternate Tilson Moving Average (T3) function to `t3()`, which allows a "series float" `length` argument.
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (float): (series int/float) Length for the smoothing parameter calculation.
    vf (simple float): (simple float) Volume factor. Affects the responsiveness.
  Returns: (float) The Tilson moving average of the `source`.

tema(source, length)
  Calculates the value of the Triple Exponential Moving Average (TEMA).
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (simple int): (simple int) Length for the smoothing parameter calculation.
  Returns: (float) The triple exponentially weighted moving average of the `source`.

tema2(source, length)
  An alternate Triple Exponential Moving Average (TEMA) function to `tema()`, which allows a "series float" `length` argument.
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (float): (series int/float) Length for the smoothing parameter calculation.
  Returns: (float) The triple exponentially weighted moving average of the `source`.

trima(source, length)
  Calculates the value of the Triangular Moving Average (TRIMA).
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (int): (series int) Number of bars (length).
  Returns: (float) The triangular moving average of the `source`.

trima2(​src, length)
  An alternate Triangular ​Moving Average (TRIMA) function to `trima()`, which allows a "series int" length argument.
  Parameters:
    ​src: (series int/float) Series of values to process.
    length: (series int) Number of bars (length).
  Returns: (float) The triangular moving average of the `​src`.

trix(source, length, signalLength, exponential)
  Calculates the values of the TRIX indicator.
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (simple int): (simple int) Length for the smoothing parameter calculation.
    signalLength (simple int): (simple int) Length for smoothing the signal line.
    exponential (simple bool): (simple bool) Condition to determine whether exponential or simple smoothing is used. Optional. The default is `true` (exponential smoothing).
  Returns: ([float, float, float]) A tuple of the TRIX value, the signal value, and the histogram.

uo(fastLen, midLen, slowLen)
  Calculates the value of the Ultimate Oscillator.
  Parameters:
    fastLen (simple int): (series int) Number of bars for the fast smoothing average (length).
    midLen (simple int): (series int) Number of bars for the middle smoothing average (length).
    slowLen (simple int): (series int) Number of bars for the slow smoothing average (length).
  Returns: (float) The oscillator value.

vhf(source, length)
  Calculates the value of the Vertical Horizontal Filter.
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (simple int): (simple int) Number of bars (length).
  Returns: (float) The oscillator value.

vi(length)
  Calculates the values of the Vortex Indicator.
  Parameters:
    length (simple int): (simple int) Number of bars (length).
  Returns: ([float, float]) A tuple of the viPlus and viMinus values.

vzo(length)
  Calculates the value of the Volume Zone Oscillator.
  Parameters:
    length (simple int): (simple int) Length for the smoothing parameter calculation.
  Returns: (float) The oscillator value.

williamsFractal(period)
  Detects Williams Fractals.
  Parameters:
    period (int): (series int) Number of bars (length).
  Returns: ([bool, bool]) A tuple of an up fractal and down fractal. Variables are true when detected.

wpo(length)
  Calculates the value of the Wave Period Oscillator.
  Parameters:
    length (simple int): (simple int) Length for the smoothing parameter calculation.
  Returns: (float) The oscillator value.

█ v7, Nov. 2, 2023

This version includes the following new and updated functions:

atr2(length)
  An alternate ATR function to the `ta.atr()` built-in, which allows a "series float" `length` argument.
  Parameters:
    length (float): (series int/float) Length for the smoothing parameter calculation.
  Returns: (float) The ATR value.

changePercent(newValue, oldValue)
  Calculates the percentage difference between two distinct values.
  Parameters:
    newValue (float): (series int/float) The current value.
    oldValue (float): (series int/float) The previous value.
  Returns: (float) The percentage change from the `oldValue` to the `newValue`.

donchian(length)
  Calculates the values of a Donchian Channel using `high` and `low` over a given `length`.
  Parameters:
    length (int): (series int) Number of bars (length).
  Returns: ([float, float, float]) A tuple containing the channel high, low, and median, respectively.

highestSince(cond, source)
  Tracks the highest value of a series since the last occurrence of a condition.
  Parameters:
    cond (bool): (series bool) A condition which, when `true`, resets the tracking of the highest `source`.
    source (float): (series int/float) Series of values to process. Optional. The default is `high`.
  Returns: (float) The highest `source` value since the last time the `cond` was `true`.

lowestSince(cond, source)
  Tracks the lowest value of a series since the last occurrence of a condition.
  Parameters:
    cond (bool): (series bool) A condition which, when `true`, resets the tracking of the lowest `source`.
    source (float): (series int/float) Series of values to process. Optional. The default is `low`.
  Returns: (float) The lowest `source` value since the last time the `cond` was `true`.

relativeVolume(length, anchorTimeframe, isCumulative, adjustRealtime)
  Calculates the volume since the last change in the time value from the `anchorTimeframe`, the historical average volume using bars from past periods that have the same relative time offset as the current bar from the start of its period, and the ratio of these volumes. The volume values are cumulative by default, but can be adjusted to non-accumulated with the `isCumulative` parameter.
  Parameters:
    length (simple int): (simple int) The number of periods to use for the historical average calculation.
    anchorTimeframe (simple string): (simple string) The anchor timeframe used in the calculation. Optional. Default is "D".
    isCumulative (simple bool): (simple bool) If `true`, the volume values will be accumulated since the start of the last `anchorTimeframe`. If `false`, values will be used without accumulation. Optional. The default is `true`.
    adjustRealtime (simple bool): (simple bool) If `true`, estimates the cumulative value on unclosed bars based on the data since the last `anchor` condition. Optional. The default is `false`.
  Returns: ([float, float, float]) A tuple of three float values. The first element is the current volume. The second is the average of volumes at equivalent time offsets from past anchors over the specified number of periods. The third is the ratio of the current volume to the historical average volume.

rma2(source, length)
  An alternate RMA function to the `ta.rma()` built-in, which allows a "series float" `length` argument.
  Parameters:
    source (float): (series int/float) Series of values to process.
    length (float): (series int/float) Length for the smoothing parameter calculation.
  Returns: (float) The rolling moving average of the `source`.

supertrend2(factor, atrLength, wicks)
  An alternate SuperTrend function to `supertrend()`, which allows a "series float" `atrLength` argument.
  Parameters:
    factor (float): (series int/float) Multiplier for the ATR value.
    atrLength (float): (series int/float) Length for the ATR smoothing parameter calculation.
    wicks (simple bool): (simple bool) Condition to determine whether to take candle wicks into account when reversing trend, or to use the close price. Optional. Default is `false`.
  Returns: ([float, int]) A tuple of the superTrend value and trend direction.

vStop(source, atrLength, atrFactor)
  Calculates an ATR-based stop value that trails behind the `source`. Can serve as a possible stop-loss guide and trend identifier.
  Parameters:
    source (float): (series int/float) Series of values that the stop trails behind.
    atrLength (simple int): (simple int) Length for the ATR smoothing parameter calculation.
    atrFactor (float): (series int/float) The multiplier of the ATR value. Affects the maximum distance between the stop and the `source` value. A value of 1 means the maximum distance is 100% of the ATR value. Optional. The default is 1.
  Returns: ([float, bool]) A tuple of the volatility stop value and the trend direction as a "bool".

vStop2(source, atrLength, atrFactor)
  An alternate Volatility Stop function to `vStop()`, which allows a "series float" `atrLength` argument.
  Parameters:
    source (float): (series int/float) Series of values that the stop trails behind.
    atrLength (float): (series int/float) Length for the ATR smoothing parameter calculation.
    atrFactor (float): (series int/float) The multiplier of the ATR value. Affects the maximum distance between the stop and the `source` value. A value of 1 means the maximum distance is 100% of the ATR value. Optional. The default is 1.
  Returns: ([float, bool]) A tuple of the volatility stop value and the trend direction as a "bool".

Removed Functions:

allTimeHigh(src)
  Tracks the highest value of `src` from the first historical bar to the current bar.

allTimeLow(src)
  Tracks the lowest value of `src` from the first historical bar to the current bar.

trima2(src, length)
  An alternate Triangular Moving Average (TRIMA) function to `trima()`, which allows a
"series int" length argument.

ta — Library by TradingView (2024)

FAQs

Is TradingView better than Thinkorswim? ›

TradingView is better for crypto trading. It has specific tools for crypto like Renko charts, crypto screener, and charting for thousands of crypto pairs. Thinkorswim mainly focuses on stocks, options and futures.

How good is TradingView technical analysis? ›

According to Google, the Technical Rating indicator in TradingView is one of the best signal indicators for identifying potential entry and exit points on trades using 11 different technical indicators.

How legit is TradingView? ›

It offers a wide range of features and tools, including real-time data, customizable charts, technical indicators, drawing tools, and social trading capabilities. While TradingView is generally well-regarded by traders and investors, there are some limitations and criticisms to consider.

What are the limitations of TradingView free account? ›

Understanding TradingView's Free Plan

However, the Basic plan does come with limitations. It restricts users to a maximum of two indicators per chart and includes ads, which might be a drawback for more advanced analysis. Plus, you don't have access to real-time data feeds.

Do professional traders use TradingView? ›

We've introduced three most comprehensive packages (Expert, Elite and Ultimate) designed specifically for Professional (Commercial) traders.

Is there a better platform than TradingView? ›

TrendSpider offers an advanced, ad-free experience that stands out from TradingView and other competing products.

Which is the most accurate indicator in TradingView? ›

Bollinger Bands is also one of the best and most used indicators in TradingView. It is a useful tool in technical analysis that follows the movement of the price of a stock or market index and uses the standard deviation to tell the volatility of the stock or the market index.

What are the top 3 indicators in TradingView? ›

The 3 Best TradingView Indicators to Improve Your Trading
  • 1- ARMAGEDDON 2 by Bullish way team. This indicator shows you the floor and ceiling of the market accurately. ...
  • 2-Ichimoku Clouds. ...
  • 3-Auto Fib Retracement.
Nov 22, 2023

Can you really make money from TradingView? ›

Earn with TradingView

Become an affiliate partner and make cash by promoting a product your followers will love. The biggest website in the world when it comes to all things investing. We are global and support 20 languages worldwide. We've paid out over $10 million to our partners and that's growing.

Who is the best broker using TradingView? ›

Best Forex Brokers for TradingView
  • Saxo - Best web-based trading platform.
  • Interactive Brokers - Great overall, best for professionals.
  • FOREX.com - Excellent all-round offering.
  • City Index - Excellent all-round offering.
  • FXCM - Excellent trading platforms and tools.
  • Capital.com - Great for beginners, easy to use.
Mar 19, 2024

How much should I pay for TradingView? ›

Free - Limited features but provides core charting and analysis tools. Pro - $14.95/month or $155.40/year. Upgrade for more indicators, alerts and customization. Pro+ - $29.95/month or $299.40/year.

Is TradingView good for beginners? ›

TradingView is perhaps the best platform today to get started in the world of trading. Although TradingView can be used by both beginners and more experienced traders, its intuitive interface and numerous tools make it especially useful for those who are just starting in the trading world.

What is the free alternative to TradingView? ›

Koyfin is the TradingView alternative.

How to get full TradingView for free? ›

You can get TradingView pro features for free if you sign up in Fyers broker. The Fyers trading panel is almost the copy-paste of the TradingView with all the premium features. If you are in Forex, you can sign up on FXCM and ask them for the premium features. There you will get 1-year premium for free.

Can I use TradingView without a broker? ›

The great thing about Tradingview is you can use it for charting and analysis even without live trading enabled. But once you connect your broker account, the platform becomes incredibly powerful.

What is the best trading platform? ›

Summary of the best online brokers:
  • Webull.
  • J.P. Morgan Self-Directed Investing.
  • Robinhood.
  • SoFi Active Investing.
  • E*TRADE.
  • Ally Invest.
  • Firstrade.
  • Public.

Why is TradingView better? ›

TradingView is a powerful charting platform and social community. It boasts a modern user-friendly interface with a wide array of indicators and screeners. Their charts support multiple asset classes such as stocks, forex, cryptocurrencies and commodities.

Is Thinkorswim compatible with TradingView? ›

No, TradingView is not compatible with TD Ameritrade. TradingView works with a variety of different brokers, but TD Ameritrade is not one of them. On the contrary, Thinkorswim is exclusive to TD Ameritrade and Schwab clients and only allows trading through a TD Ameritrade or Schwab account.

Top Articles
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 5608

Rating: 4.7 / 5 (77 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.