A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (2024)

Featured Image via Canva.

  • The objective of this study is to propose a comprehensive stock technical analysis (TA) guide using the TA-Lib Python library.
  • TA is the most common way used by investors and traders to analyze the stock market and make investment decisions. The idea of TA is to capture short term profits by detecting the turning points of price swings.
  • One form of TA makes use of technical indicators. Technical indicators are functions of price and volume which we can use as signals for entering or exiting positions. Acoreprinciple ofTAis that a market’s price reflects all relevant information impacting that market.
  • TA-Lib is widely used by traders and investors requiring to calculate numerous technical indicators of financial market data.
  • In this article, we will explore ways to incorporate TA-Lib into our algo trading portfolio by integrating more than 200 technical indicators.
  • In the sequel, we will download the Tesla historical data to analyze thestock’sprice movements and identify potential trends.
  • Equipped with updated technical indicators, our TA will offer an integrated perspective for both swing traders and long-term holders considering their positions in TSLA.

Table of Contents

  1. Why Tesla
  2. About TA-LIB
  3. Input Stock Data
  4. Momentum Indicators
  5. Volume Indicators
  6. Volatility Indicators
  7. Trend Indicators
  8. Other Indicators
  9. Conclusions
  10. Explore More
  11. Infographic
  12. Embed Socials

Why Tesla

  • Tesla’s release positioned it as one of the few successful independent automakers and a pioneer in the electric car market.
  • Tesla Inc. (TSLA) remains a highly watched stock in the market, with its daily price movements offering significant insights for investors.
  • TSLA demonstrated notable financial and operational progress in Q3 2023, with a 9% increase in revenue driven by vehicle deliveries and expansion across business segments.
  • Tesla’s stock shows a pronounced bullish trend, with potential for an upward trajectory in stock value, supported by falling wedge and bull flag patterns.
  • TSLA is part of a very strong bullish trend. Traders may consider trading only long positions as long as the price remains well above254.49 USD. The next resistance located at294.36 USDis the next bullish objective to be reached.

About TA-LIB

  • TA-LIB is anopen-sourceTAPython library used by traders, investors and analysts to perform complex calculations on financial data and build trading strategies.
  • This library is useful to do feature engineering from financial time series datasets (Open, Close, High, Low, Volume). It is built on Pandas and Numpy.
  • The library is written in C language and provides 200technical indicators and trading functions. These indicators are used to identify trends, measure momentum, and assess the overall strength and direction of a market.
  • Read more about installing and downloading TA-LIB here.

Input Stock Data

  • Let’s set the working directory YOURPATH and import the key libraries
import osos.chdir('YOURPATH') # Set working directoryos. getcwd()
import numpy as np import pandas as pd import matplotlib.pyplot as pltimport seaborn as snsimport taimport yfinance as yfimport mplfinance as mpfimport matplotlib.pyplot as pltfrom datetime import datetime, timedeltaimport warningswarnings.filterwarnings("ignore")
  • Downloading and plotting the input stock data
ticker = "TSLA"end_date = datetime.today().strftime('%Y-%m-%d')start_date = (datetime.today() - timedelta(days=300)).strftime('%Y-%m-%d')data = yf.download(ticker, start=start_date, end=end_date, interval='1h')[*********************100%%**********************] 1 of 1 completedmpf.plot(data, type='candle', volume=True, style='yahoo')
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (1)

Momentum Indicators

  • Implementing the Momentum Indicators.
  • Relative Strength Index (RSI) is a momentum oscillator that measures the speed and change of price movements. It helps traders identify overbought or oversold conditions in a market, indicating potential price reversals.
  • Calculating and plotting the RSI indicator for TSLA
data['RSI'] = ta.momentum.RSIIndicator(data['Close']).rsi()upper_limit = 70lower_limit = 30plt.figure(figsize=(10, 6))plt.plot(data.index, data['RSI'])plt.axhline(y=upper_limit, color='r', linestyle='--', label='Overbought (70)')plt.axhline(y=lower_limit, color='g', linestyle='--', label='Oversold (30)')plt.title('RSI of Tesla Stock')plt.xlabel('Date')plt.ylabel('RSI')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (2)
  • Considering the RSI backtesting example:
# Define the initial capital and track the current capitalinitial_capital = 100current_capital = initial_capital# Define the overbought and oversold limitsoverbought_limit = 70oversold_limit = 30# Define the initial holding statusis_holding = False# Iterate through the RSI data and make buy/sell decisionsfor i in range(1, len(data)): current_rsi = data['RSI'][i] current_price = data['Close'][i] if current_rsi < oversold_limit and not is_holding: # Buy condition shares_to_buy = current_capital / current_price current_capital = 0 is_holding = True print(f"Buy {shares_to_buy} shares at {current_price} -> Rsi Level: {current_rsi}") elif current_rsi > overbought_limit and is_holding: # Sell condition current_capital = current_capital + (current_price * shares_to_buy) is_holding = False print(f"Sell {shares_to_buy} shares at {current_price} -> Rsi Level: {current_rsi}")# Print the final capitalprint(f"Final capital: ${current_capital}")Buy 0.4996502463523649 shares at 200.13999938964844 -> Rsi Level: 29.319278336969305Sell 0.4996502463523649 shares at 193.75999450683594 -> Rsi Level: 71.66474475510871Buy 0.5441438935969963 shares at 177.91659545898438 -> Rsi Level: 24.541735862296534Sell 0.5441438935969963 shares at 170.13180541992188 -> Rsi Level: 70.36655102529855Buy 0.34178611840993667 shares at 270.8599853515625 -> Rsi Level: 28.74561652656871Sell 0.34178611840993667 shares at 249.2200927734375 -> Rsi Level: 72.97586173870556Buy 0.34119755746566044 shares at 249.64999389648438 -> Rsi Level: 27.047723820596644Sell 0.34119755746566044 shares at 216.43080139160156 -> Rsi Level: 71.75336194392426Buy 0.32190770870298985 shares at 229.4001007080078 -> Rsi Level: 27.72870725152937Sell 0.32190770870298985 shares at 252.27999877929688 -> Rsi Level: 72.84438799406777Final capital: $81.21087635863654
  • When market volatility is low, Kaufman’s Adaptive Moving Average (KAMA) remains near the current market price, but when volatility increases, it will lag behind. What the KAMA indicator aims to do is filter out “market noise” – insignificant, temporary surges in price action. One of the primary weaknesses of traditional moving averages is that when used for trading signals, they tend to generate many false signals. The KAMA indicator seeks to lessen this tendency – generate fewer false signals – by not responding to short-term, insignificant price movements.
  • Calculating and plotting the KAMA indicator for TSLA in ’23
indicator_kama=ta.momentum.KAMAIndicator(close=data["Close"], window=20)data['kama']=indicator_kama.kama()plt.figure(figsize=(10,6))plt.plot(data["Close"], label='Tesla Prices', color='blue')plt.plot(data['kama'], label='KAMA', color='red')plt.title('KAMA for Tesla Prices')plt.xlabel('Date')plt.ylabel('KAMA')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (3)
  • Basically, when the KAMA indicator line is moving lower, it indicates the existence of a downtrend. On the other hand, when the KAMA line is moving higher, it shows an uptrend. As compared to the Simple Moving Average (SMA), the KAMA indicator is less likely to generate false signals that may cause a trader to incur losses.
  • The percentage price oscillator (PPO) is a technicalmomentum indicatorthat shows the relationship between two moving averages in percentage terms. The moving averages are a 26-period and 12-periodexponential moving average(EMA).
  • As with its cousin, MACD, the PPO is shown with a signal line, a histogram, and a centerline. Trading signals are generated with signal line crossovers, centerline crossovers, and divergences. These signals are similar to those associated with MACD so we will focus on a few differences between the two.
  • Calculating and plotting the PPO centerline, histogram, and signal
indicator_ppo=ta.momentum.PercentagePriceOscillator(close=data["Close"])data['ppo'] =indicator_ppo.ppo()plt.figure(figsize=(10,6))plt.plot(data['ppo'], label='PPO', color='red',lw=2)plt.title('PPO for Tesla Prices')plt.xlabel('Date')plt.ylabel('PPO')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (4)
plt.figure(figsize=(10,6))plt.plot(indicator_ppo.ppo_hist(), label='PPO Hist', color='red',lw=2)plt.title('PPO Hist for Tesla Prices')plt.xlabel('Date')plt.ylabel('PPO Hist')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (5)
plt.figure(figsize=(10,6))plt.plot(indicator_ppo.ppo_signal(), label='PPO Signal', color='red',lw=2)plt.title('PPO Signal for Tesla Prices')plt.xlabel('Date')plt.ylabel('PPO Signal')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (6)
  • The PPO histogram represents the difference between PPO and its 9-day EMA, the signal line. The histogram is positive when PPO is above its 9-day EMA and negative when PPO is below its 9-day EMA. The PPO-Histogram can be used to anticipate signal line crossovers in the PPO.
  • The Percentage Volume Oscillator (PVO) is a momentum oscillator for volume. The PVO measures the difference between two volume-based moving averages as a percentage of the larger moving average. As with MACD and thePercentage Price Oscillator (PPO), it is shown with a signal line, a histogram and a centerline. The PVO is positive when the shorter volume EMA is above the longer volume EMA and negative when the shorter volume EMA is below. This indicator can be used to define the ups and downs for volume, which can then be used to confirm or refute other signals. Typically, a breakout or support break is validated when the PVO is rising or positive.
  • Calculating and plotting the PVO centerline, histogram, and signal
data1 = yf.download('TSLA', start='2023-01-01', end='2023-12-24')indicator_pvo=ta.momentum.PercentageVolumeOscillator(volume=data1["Volume"])plt.figure(figsize=(10,6))plt.plot(indicator_pvo.pvo(), label='PVO', color='red',lw=2)plt.title('PVO for Tesla Prices')plt.xlabel('Date')plt.ylabel('PVO')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (7)
plt.figure(figsize=(10,6))plt.plot(indicator_pvo.pvo_hist(), label='PVO Hist', color='red',lw=2)plt.title('PVO Hist for Tesla Prices')plt.xlabel('Date')plt.ylabel('PVO Hist')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (8)
plt.figure(figsize=(10,6))plt.plot(indicator_pvo.pvo_signal(), label='PVO Signal', color='red',lw=2)plt.title('PVO Signal for Tesla Prices')plt.xlabel('Date')plt.ylabel('PVo Signal')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (9)
  • The PVO-Histogram acts just like the MACD and PPO histograms. The PVO-Histogram is positive when the PVO is trading above its signal line (9-day EMA). The PVO-Histogram is negative when the PVO is below its signal line.
  • The aforementioned Relative Strength Index (RSI) is a momentum oscillator that measures the speed and change of price movements.The RSI oscillates between zero and 100. Traditionally the RSI is considered overbought when above 70 and oversold when below 30. Signals can be generated by looking for divergences and failure swings. RSI can also be used to identify the general trend.
  • Calculating and plotting the RSI indicator
indicator_rsi=ta.momentum.RSIIndicator(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_rsi.rsi(), label='RSIIndicator', color='red',lw=2)plt.title('RSIIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('RSI')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (10)
  • In an uptrend or bull market, the RSI tends to remain in the 40 to 90 range with the 40-50 zone acting as support. During a downtrend or bear market the RSI tends to stay between the 10 to 60 range with the 50-60 zone acting as resistance.
indicator_stoch=ta.momentum.StochRSIIndicator(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_stoch.stochrsi(), label='Stochrsi', color='red',lw=2)plt.plot(indicator_stoch.stochrsi_d(), label='Stochrsi_d', color='green',lw=2)plt.plot(indicator_stoch.stochrsi_k(), label='Stochrsi_k', color='black',lw=2)plt.title('StochRSIIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('StochRSIIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (11)
  • In fact, StochRSI is an indicator of an indicator, which makes it the second derivative of price.A move above .80 is considered overbought, while a move below .20 is considered oversold. Second, it can be used to identify the short-term trend. As a bound oscillator, the centerline is at .50. StochRSI reflects an uptrend when consistently above .50 and a downtrend when consistently below .50.
  • TheAwesome Oscillatoris an indicator used to measure market momentum. AO calculates the difference of a 34 Period and 5 Period Simple Moving Averages. The Simple Moving Averages that are used are not calculated using closing price but rather each bar’s midpoints. AO is generally used to affirm trends or to anticipate possible reversals.
  • Because of its nature as an oscillator, AO is designed to have values that fluctuate above and below a Zero Line.
  • Calculating and plotting AO
indicator_aoi=ta.momentum.AwesomeOscillatorIndicator(high=data1["High"],low=data1["Low"])plt.figure(figsize=(10,6))plt.plot(indicator_aoi.awesome_oscillator(), label='AwesomeOscillatorIndicator', color='red',lw=2)plt.title('AwesomeOscillatorIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('AwesomeOscillator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (12)
  • When AO crosses above the Zero Line, short term momentum is now rising faster than the long term momentum. This can present a bullish buying opportunity.
  • When AO crosses below the Zero Line, short term momentum is now falling faster then the long term momentum. This can present a bearish selling opportunity.
  • The Rate-of-Change (ROC) indicator, which is also referred to as simply Momentum, is a pure momentum oscillator. The ROC calculation compares the current price with the price “n” periods ago. The plot forms an oscillator that fluctuates above and below the zero line as the Rate-of-Change moves from positive to negative.
  • An upward surge in the Rate-of-Change reflects a sharp price advance. A downward plunge indicates a steep price decline.
  • Calculating and plotting ROC
indicator_roc=ta.momentum.ROCIndicator(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_roc.roc(), label='ROCIndicator', color='red',lw=2)plt.title('ROCIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('ROCIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (13)
  • The Stochastic Oscillator (SO) is a momentum indicator that shows the location of the close relative to the high-low range over a set number of periods. The indicator can range from 0 to 100.
  • Generally, the area above 80 indicates an overbought region, while the area below 20 is considered an oversold region. A sell signal is given when the oscillator is above the 80 level and then crosses back below 80. Conversely, a buy signal is given when the oscillator is below 20 and then crosses back above 20. 80 and 20 are the most common levels used but can be adjusted as needed.
  • Calculating and plotting SO
indicator_stoch=ta.momentum.StochasticOscillator(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_stoch.stoch(), label='StochasticOscillator', color='red',lw=2)plt.title('StochasticOscillator for Tesla Prices')plt.xlabel('Date')plt.ylabel('StochasticOscillator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (14)
  • The True Strength Index (TSI) is a momentum oscillator based on a double smoothing of price changes. TSI is an oscillator that fluctuates between positive and negative territory. As with many momentum oscillators, the centerline defines the overall bias. The bulls have the momentum edge when TSI is positive and the bears have the edge when it’s negative.
  • Calculating and plotting TSI
indicator_tsi=ta.momentum.TSIIndicator(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_tsi.tsi(), label='TSIIndicator', color='red',lw=2)plt.title('TSIIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('TSIIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (15)
  • The Ultimate Oscillator (UO) is amomentum oscillatorthat combines the effects of three different timeframes to measure the momentum of an asset. The three timeframes are typically 7, 14, and 28 periods.
  • When UO reaches a level above 70, this is considered overbought, and a sell signal may be generated. Conversely, when the Ultimate Oscillator reaches a level below 30, this is considered oversold, and a buy signal may be generated.
  • Calculating and plotting UO
indicator_uo=ta.momentum.UltimateOscillator(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_uo.ultimate_oscillator(), label='UltimateOscillator', color='red',lw=2)plt.title('UltimateOscillator for Tesla Prices')plt.xlabel('Date')plt.ylabel('UltimateOscillator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (16)
  • TheWilliams Percent Range, akaWilliams %R, is a momentumindicatorthat shows youwhere the last closing price is relative to the highest and lowest pricesof a given time period.
  • Normally, Williams %R uses the0 to -100scale: A readingabove -20isOVERBOUGHT; A readingbelow -80isOVERSOLD.
  • Calculating and plotting Williams %R
indicator_wri=ta.momentum.WilliamsRIndicator(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_wri.williams_r(), label='WilliamsRIndicator', color='red',lw=2)plt.title('WilliamsRIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('WilliamsRIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (17)

Volume Indicators

  • Let’s dive deeper at volume indicators and how to trade them.
  • The Accumulation/Distribution (A/D) index indicator provides information regarding the money flow in a stock. The word “accumulation” refers to the level of buying and “distribution” the level of selling. The indicator fluctuates above and below the zero line.
  • The bullish trend confirmation signal comes when the accumulation distribution indicator line increases during times of high volume. The bearish trend confirmation signal comes when the accumulation distribution indicator line decreases during times of high volume. This signal occurs when price is likely on the decline.
  • Calculating and plotting A/D
indicator_adi=ta.volume.AccDistIndexIndicator(high=data1["High"],low=data1["Low"],close=data1["Close"],volume=data1['Volume'])plt.figure(figsize=(10,6))plt.plot(indicator_adi.acc_dist_index(), label='AccDistIndexIndicator', color='red',lw=2)plt.title('AccDistIndexIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('AccDistIndex')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (18)
  • Chaikin Money Flow (CMF) is a volume-weighted average of accumulation and distribution over a specified period. A CMF value above the zero line is a sign of strength in the market, and a value below the zero line is a sign of weakness in the market.
  • Calculating and plotting CMF
indicator_cmfi=ta.volume.ChaikinMoneyFlowIndicator(high=data1["High"],low=data1["Low"],close=data1["Close"],volume=data1['Volume'])plt.figure(figsize=(10,6))plt.plot(indicator_cmfi.chaikin_money_flow(), label='ChaikinMoneyFlowIndicator', color='red',lw=2)plt.title('ChaikinMoneyFlowIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('ChaikinMoneyFlowIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (19)
  • The Ease of Movement (EOM) indicatoraims to explain the relationship between the price of an asset and the volume.Ideally, abuying opportunity usually emerges when the ease of movement indicator has moved substantially below the neutral line.
  • Calculating and plotting EOM
indicator_eomi=ta.volume.EaseOfMovementIndicator(high=data1["High"],low=data1["Low"],volume=data1['Volume'])plt.figure(figsize=(10,6))plt.plot(indicator_eomi.ease_of_movement(), label='EaseOfMovementIndicator', color='red',lw=2)plt.title('EaseOfMovementIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('EaseOfMovementIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (20)
  • The Force Index (FI) is an indicator that uses price and volume to assess the power behind a move or identify possible turning points. A positive price change signals that buyers were stronger than sellers, while a negative price change signals that sellers were stronger than buyers.A bullish divergence is confirmed when FI crosses into positive territory. A bearish divergence is confirmed when FI crosses into negative territory.
  • Calculating and plotting FI
indicator_fii=ta.volume.ForceIndexIndicator(close=data1["Close"],volume=data1['Volume'])plt.figure(figsize=(10,6))plt.plot(indicator_fii.force_index(), label='ForceIndexIndicator', color='red',lw=2)plt.title('ForceIndexIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('ForceIndexIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (21)
  • The Money Flow Index (MFI) is an oscillator that uses both price and volume to measure buying and selling pressure. Money flow is positive when the typical price rises (buying pressure) and negative when the typical price declines (selling pressure).
  • Typically, MFI above 80 is considered overbought and MFI below 20 is considered oversold. Strong trends can present a problem for these classic overbought and oversold levels. MFI can become overbought (>80) and prices can simply continue higher when the uptrend is strong. Conversely, MFI can become oversold (<20) and prices can simply continue lower when the downtrend is strong.
  • Calculating and plotting MFI
indicator_mfii=ta.volume.MFIIndicator(high=data1["High"],low=data1["Low"],close=data1["Close"],volume=data1['Volume'])plt.figure(figsize=(10,6))plt.plot(indicator_mfii.money_flow_index(), label='MFIIndicator', color='red',lw=2)plt.title('MFIIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('MFIIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (22)
  • The Negative Volume Index (NVI) is a technical indicator used to identify trends in a market. It is a cumulative indicator, which means that all changes to the indicator accumulate.The NVI is used to generate buy signals whenever the NVI crosses above its exponential weighted moving average (EWMA).
  • Calculating and plotting the NVI
indicator_nvii=ta.volume.NegativeVolumeIndexIndicator(close=data1["Close"],volume=data1['Volume'])plt.figure(figsize=(10,6))plt.plot(indicator_nvii.negative_volume_index(), label='NegativeVolumeIndexIndicator', color='red',lw=2)plt.title('NegativeVolumeIndexIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('NegativeVolumeIndexIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (23)
  • On-Balance Volume Indicator (OBV) tracks increasing or decreasing volume to project future price movements. For example, if a stock’s price continues to rise, but the on-balance volume indicator begins to decline, that may be interpreted that the previous buying momentum in the stock is beginning to wane. The stock price may soon peak and turn to the downside.
  • Calculating and plotting OBV
indicator_obvi=ta.volume.OnBalanceVolumeIndicator(close=data1["Close"],volume=data1['Volume'])plt.figure(figsize=(10,6))plt.plot(indicator_obvi.on_balance_volume(), label='OnBalanceVolumeIndicator', color='red',lw=2)plt.title('OnBalanceVolumeIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('OnBalanceVolumeIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (24)
  • The Volume Price Trend Indicator (VPT) is a stock market indicator that helps traders relate a stock’s price and trading volume. An increase in price, as well as volume, confirms the price trend upward. A decrease in price, as well as volume, confirms the price trend downward.
  • Calculating and plotting VPT
indicator_vpt=ta.volume.VolumePriceTrendIndicator(close=data1["Close"],volume=data1['Volume'])plt.figure(figsize=(10,6))plt.plot(indicator_vpt.volume_price_trend(), label='VolumePriceTrendIndicator', color='red',lw=2)plt.title('VolumePriceTrendIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('VolumePriceTrendIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (25)
  • The volume-weighted average price (VWAP) measures a stock’s average price during a time period, adjusted for volume.VWAP is the average price weighted by volume.Prices below VWAP values are relatively low for that day or that specific time. By contrast, prices above VWAP values are relatively high for that day or that specific time.
  • Calculating and plotting VWAP
indicator_vwa=ta.volume.VolumeWeightedAveragePrice(high=data1["High"],low=data1["Low"],close=data1["Close"],volume=data1['Volume'])plt.figure(figsize=(10,6))plt.plot(indicator_vwa.volume_weighted_average_price(), label='VolumeWeightedAveragePrice', color='red',lw=2)plt.title('VolumeWeightedAveragePrice for Tesla Prices')plt.xlabel('Date')plt.ylabel('VolumeWeightedAveragePrice')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (26)

Volatility Indicators

  • Let’s look at the volatility indicators.
  • The Average True Range (ATR) is an indicator that measuresvolatility.ATR doesn’t indicate price direction, just volatility. A higher ATR signals more volatility, and vice versa.
  • Calculating and plotting ATR
indicator_vatr=ta.volatility.AverageTrueRange(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_vatr.average_true_range(), label='AverageTrueRange', color='red',lw=2)plt.title('AverageTrueRange for Tesla Prices')plt.xlabel('Date')plt.ylabel('AverageTrueRange')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (27)
  • Bollinger Bands (BB) help you identify sharp, short-term price movements and potential entry and exit points. They’re designed to help traders evaluate price action and a stock’s volatility. BB are unique in that they comprise both a moving averageandstandard deviations.
  • Calculating and plotting BB
indicator_bb=ta.volatility.BollingerBands(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_bb.bollinger_hband(), label='BB High Band', color='red',lw=2)#plt.plot(indicator_bb.bollinger_hband_indicator(), label='BB High Band Indicator', color='red',lw=2)plt.plot(indicator_bb.bollinger_lband(), label='BB Low Band', color='blue',lw=2)#plt.plot(indicator_bb.bollinger_lband_indicator(), label='BB Low Band Indicator', color='red',lw=2)plt.plot(indicator_bb.bollinger_mavg(), label='BB MAVG', color='green',lw=2)plt.title('BollingerBands for Tesla Prices')plt.xlabel('Date')plt.ylabel('BollingerBands')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (28)
  • Another indicator used with BB is Bollinger Channel Percentage Band (%b), whichplots the stock’s closing price as a percentage of the upper and lower bands. The upper band is identified as 1.0, the middle band 0.5 and the lower band zero. Thus, %b shows how close the stock’s current price is to the bands.
  • If the closing price is equal to the upperBBvalue, %b would be 1.0. If the closing price is equal to the moving average, %b is 0.5. If the closing price is equal to the lower BB, %b would be zero.
  • Calculating and plotting %b
plt.figure(figsize=(10,6))plt.plot(indicator_bb.bollinger_pband(), label='Bollinger Channel Percentage Band', color='brown',lw=2)plt.title('Bollinger Channel Percentage Band for Tesla Prices')plt.xlabel('Date')plt.ylabel('Bollinger Channel Percentage Band')plt.legend()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (29)
  • The BB Width isthe difference between the upper and the lower BB divided by the middle band. This technical indicator provides an easy way to visualize consolidation before price movements (low bandwidth values) or periods of higher volatility (high bandwidth values).
  • Calculating and plotting the BB Width
plt.figure(figsize=(10,6))plt.plot(indicator_bb.bollinger_wband(), label='Bollinger Channel Band Width', color='orange',lw=2)plt.title('Bollinger Channel Band Width for Tesla Prices')plt.xlabel('Date')plt.ylabel('Bollinger Channel Band Width')plt.legend()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (30)
  • Donchian Channel is a volatility indicator that helps technical analysts to identify and define price trends as well as determine the optimal entry and exit points in ranging markets. Ideally,if there is substantial volatility in a certain period, the Donchian Channels will be substantially wide. Similarly, if there is minimal volatility in a certain period, the Donchian channels will be relatively narrow.
  • Calculating and plotting the Donchian Channel
plt.figure(figsize=(10,6))plt.plot(indicator_dc.donchian_channel_hband(), label='Donchian Channel High Band', color='red',lw=2)plt.plot(indicator_dc.donchian_channel_lband(), label='Donchian Channel Low Band', color='blue',lw=2)plt.plot(indicator_dc.donchian_channel_mband(), label='Donchian Channel Middle Band', color='green',lw=2)plt.title('DonchianChannel for Tesla Prices')plt.xlabel('Date')plt.ylabel('DonchianChannel')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (31)
  • Computing and plotting the Donchian Channel Percentage Band for Tesla Prices
indicator_dc=ta.volatility.DonchianChannel(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_dc.donchian_channel_pband(), label='Donchian Channel Percentage Band', color='brown',lw=2)plt.title('Donchian Channel Percentage Band for Tesla Prices')plt.xlabel('Date')plt.ylabel('Donchian Channel Percentage Band')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (32)
  • Calculating and plotting the Donchian Channel Band Width for Tesla Prices
indicator_dc=ta.volatility.DonchianChannel(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_dc.donchian_channel_wband(), label='Donchian Channel Band Width', color='orange',lw=2)plt.title('Donchian Channel Band Width for Tesla Prices')plt.xlabel('Date')plt.ylabel('Donchian Channel Band Width')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (33)
  • Keltner Channels (KC) are volatility-based envelopes set above and below an exponential moving average. This indicator is similar to Bollinger Bands, which use the standard deviation to set the bands. Instead of using the standard deviation, Keltner Channels use the Average True Range (ATR) to set channel distance. The channels are typically set two Average True Range values above and below the 20-day EMA. The exponential moving average dictates direction and the Average True Range sets channel width.Keltner Channels are a trend following indicator used to identify reversals with channel breakouts and channel direction.Channels can also be used to identify overbought and oversold levels when the trend is flat.
  • Calculating and plotting KC
indicator_kc=ta.volatility.KeltnerChannel(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_kc.keltner_channel_hband(), label='KC High Band', color='red',lw=2)plt.plot(indicator_kc.keltner_channel_lband(), label='KC Low Band', color='blue',lw=2)plt.plot(indicator_kc.keltner_channel_mband(), label='KC MBand', color='green',lw=2)plt.title('KeltnerChannel for Tesla Prices')plt.xlabel('Date')plt.ylabel('KeltnerChannel')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (34)
  • Calculating and plotting the Keltner Channel Percentage Band for Tesla Prices
indicator_kc=ta.volatility.KeltnerChannel(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_kc.keltner_channel_pband(), label='Keltner Channel Percentage Band', color='brown',lw=2)plt.title('Keltner Channel Percentage Band for Tesla Prices')plt.xlabel('Date')plt.ylabel('Keltner Channel Percentage Band')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (35)
  • Calculating and plotting the Keltner Channel Band Width for Tesla Prices
indicator_kc=ta.volatility.KeltnerChannel(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_kc.keltner_channel_wband(), label='Keltner Channel Band Width', color='orange',lw=2)plt.title('Keltner Channel Band Width for Tesla Prices')plt.xlabel('Date')plt.ylabel('Keltner Channel Band Width')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (36)
  • The Ulcer Index (UI) is atechnical indicatorthat measures volatility in a stock. It helps traders like you know the maximum loss or profit in a trade and determine suitable entry and exit points.
  • The UI primarily measures the downside risk of a stock. It is the maximum potential for a decline in a stock’s value under volatile market conditions. As an investor, you buy a stock expecting an upsurge in its price, but the only risk you face is the downside risk.
  • The UI gives you an idea of the maximum drawdown you can expect during a specified trading window. You don’t mind the upward surge in price, but the downside risk can cause stomach stress or ulcers, as the name of the indicator suggests.
  • Calculating and plotting the UI
indicator_ui=ta.volatility.UlcerIndex(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_ui.ulcer_index() , label='UI', color='red',lw=2)plt.title('Ulcer Index (UI) for Tesla Prices')plt.xlabel('Date')plt.ylabel('UI')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (37)

Trend Indicators

  • Let’s examine the trend indicators. After all, a top priority in trading is being able tofind a trend, because that is where the most money is made.
  • The average directional index (ADX) isa technical analysis indicator used by some traders to determine the strength of a trend. The trend can be either up or down, and this is shown by two accompanying indicators, the negative directional indicator (-DI) and the positive directional indicator (+DI).
  • Trading in the direction of a strongtrendreduces risk and increases profit potential. TheADXis used to determine when the price is trending strongly.
  • Calculating and plotting the ADX indicator
indicator_adx=ta.trend.ADXIndicator(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_adx.adx(), label='ADX', color='green',lw=2)plt.plot(indicator_adx.adx_neg(), label='-DI', color='blue',lw=2)plt.plot(indicator_adx.adx_pos(), label='+DI', color='red',lw=2)plt.title('Average Directional Index for Tesla Prices')plt.xlabel('Date')plt.ylabel('Average Directional Index')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (38)
  • As we can see, the ADX chart features three lines: the ADX, the positive directional indicator (+DI) and the negative directional indicator (-DI). The +DI line indicates the strength of positive movement. The -DI line indicates the strength of negative movement. The ADX line indicates the strength of movement over the period.
  • The ADX indicator is measured on a scale from 0 to 100. The higher the ADX reading, the greater the strength of a trend.
  • ADX below 20: The market is currently not trending.
  • ADX crosses above 20: A new trend is emerging.
  • ADX between 20 and 40: This is considered as a confirmation of an emerging trend.
  • ADX above 40: The trend is very strong.
  • ADX crosses 50: the trend is extremely strong.
  • ADX crosses 70: A very rare occasion, called a “power trend”.
  • The Aroon indicator actually consists of two indicators that together are designed to:
  • Identify trend changes or the beginning of a trend
  • Identify the existence of a trending or rangingmarket
  • Spot corrective retracements or consolidation periods
  • Gauge the strength of a trend.
  • Calculating and plotting the Aroon indicator
indicator_aro=ta.trend.AroonIndicator(high=data1["High"],low=data1["Low"])plt.figure(figsize=(10,6))plt.plot(indicator_aro.aroon_down(), label='Aroon Down Channel', color='blue',lw=2)plt.plot(indicator_aro.aroon_indicator(), label='Aroon Indicator', color='green',lw=2)plt.plot(indicator_aro.aroon_up(), label='Aroon Up Channel', color='red',lw=2)plt.title('Aroon Indicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('Aroon Indicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (39)
  • Trading signals can be obtained from Aroon crossovers. Crossovers of the two Aroon indicators, either the Aroon-Up indicator making a bullish crossover above the Aroon-Down indicator, or the Aroon-Down indicator making a bearish crossover to above the Aroon-Up indicator, are generally interpreted as trend change or market reversal signals.
  • The Commodity Channel Index (CCI) indicator measures an asset’s current price compared to the average price level established over a given period. It tracks the momentum of current price highs and lows relative to the statistical mean to determine the development of newtrendsin the market.
  • When the CCI moves above +100, the financial instrument’s level will signal an upward trend and provide an opportunity for traders to buy at a given time. Conversely, when the CCI moves below −100, a downturn in the level of the asset’s price will be observed and there’ll be a signal to sell.
  • Calculating and plotting the CCI indicator
indicator_cci=ta.trend.CCIIndicator(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_cci.cci(), label='CCI', color='red',lw=2)plt.title('Commodity Channel Index (CCI) for Tesla Prices')plt.xlabel('Date')plt.ylabel('CCI')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (40)
  • The Detrended Price Oscillator (DPO) is an indicator designed to remove trend from price and make it easier to identify cycles.
  • One of the most effective ways of using the DPO indicator is to use thezero line. This is the line thatappears in the middle. You should focuson the line when it crosses the zero line. If the DPO line moves lowerand remains below zero, itis usuallysaid to bea sell signal.
  • Calculating and plotting the DPO indicator
indicator_dpo=ta.trend.DPOIndicator(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_dpo.dpo(), label='DPO', color='red',lw=2)plt.title('Detrended Price Oscillator (DPO) for Tesla Prices')plt.xlabel('Date')plt.ylabel('DPO')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (41)
  • The Exponential Moving Average (EMA) is a technical indicator used in trading practices that shows how the price of an asset orsecuritychanges over a certain period of time. The EMA is different from a simple moving average in that it places more weight on recent data points (i.e., recent prices).
  • The aim of all moving averages is to establish the direction in which the price of a security is moving based on past prices. Therefore, exponential moving averages are lag indicators. They are not predictive of future prices; they simply highlight the trend that is being followed by the stock price.
  • Calculating and plotting the EMA indicator
indicator_ema=ta.trend.EMAIndicator(close=data1["Close"],window=20)plt.figure(figsize=(10,6))plt.plot(indicator_ema.ema_indicator(), label='EMA20', color='red',lw=2)indicator_ema=ta.trend.EMAIndicator(close=data1["Close"],window=50)plt.plot(indicator_ema.ema_indicator(), label='EMA50', color='blue',lw=2)plt.title('Exponential Moving Average (EMA) for Tesla Prices')plt.xlabel('Date')plt.ylabel('EMA')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (42)
  • The Ichimoku Cloud is a multi-functional tool that provides various insights into market dynamics. The cloud, comprised of the Leading Span A and Leading Span B lines, can be used to identify the trend. The relationships between price, the Conversion Line, and the Base Line are used to identify shorter-term trading signals.
  • Calculating and plotting the Ichimoku Cloud
indicator_ichi=ta.trend.IchimokuIndicator(high=data1["High"],low=data1["Low"])plt.figure(figsize=(10,6))plt.plot(indicator_ichi.ichimoku_a(), label='Leading Span A', color='red',lw=2)plt.plot(indicator_ichi.ichimoku_b(), label='Leading Span B', color='blue',lw=2)plt.plot(indicator_ichi.ichimoku_base_line(), label='Base Line', color='green',lw=2)plt.plot(indicator_ichi.ichimoku_conversion_line(), label='Conversion Line', color='orange',lw=2)plt.title('IchimokuIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('IchimokuIndicator')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (43)
  • There are two ways to identify the overall trend using the cloud.First, the trend is up when prices are above the cloud, down when prices are below the cloud, and flat when prices are in the cloud.Second, the uptrend is strengthened when the Leading Span A rises above the Leading Span B. Conversely, a downtrend is reinforced when the Leading Span A falls below the Leading Span B.
  • During an uptrend, a bullish signal is triggered when the Conversion Line crosses above the Base Line. Similarly, the Conversion Line crossing below the Base Line during a downtrend is a bearish signal.
  • The Know Sure Thing (KST) indicator helps to determine the divergences as well as the centerline and signal line crossovers.
  • The KST oscillates around the zero line. Its reading is positive when it moves above the zero line and negative when it goes below it. When the indicator fluctuates above the middle line it signifies the bulls dominance and the price is rising. The negative reading reflects the bears in control over the market and thus the price is falling.
  • Another type of signals produced by the KST is the signal line crossover. When the KST line is rising above the signal line and the reading is negative, this signifies the end of the downtrend. When the KST is falling below the signal line and the reading is positive, the uptrend is coming to an end.
  • Calculating and plotting the KST indicator
indicator_kst=ta.trend.KSTIndicator(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_kst.kst(), label='KST', color='red',lw=2)plt.plot(indicator_kst.kst_sig(), label='KST Signal', color='blue',lw=2)plt.title('KST Oscillator (KST Signal) for Tesla Prices')plt.xlabel('Date')plt.ylabel('KST')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (44)
  • Calculating and plotting the difference KST – (KST Signal)
plt.figure(figsize=(10,6))plt.plot(indicator_kst.kst_diff(), label='Diff KST', color='red',lw=2)plt.title('Diff KST for Tesla Prices')plt.xlabel('Date')plt.ylabel('Diff KST')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (45)
  • The MovingAverageConvergenceDivergence (MACD) indicator is a tool that’s used to identify moving averages that are indicating a new trend, whether it’s bullish or bearish.
  • There are two lines:
  • The “MACD Line“
  • The “Signal Line“
  • The Signal Line is considered the “slower” moving average.
  • TheHistogramsimply plotsthedifferencebetween the MACD Line and Signal Line.
  • Calculating and plotting the MACD indicator
indicator_macd=ta.trend.MACD(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_macd.macd(), label='MACD', color='red',lw=2)plt.plot(indicator_macd.macd_signal(), label='MACD Signal', color='blue',lw=2)plt.title('MACD for Tesla Prices')plt.xlabel('Date')plt.ylabel('MACD')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (46)
  • Calculating and plotting the difference MACD – (MACD Signal)
plt.figure(figsize=(10,6))plt.plot(indicator_macd.macd_diff(), label='Diff MACD', color='red',lw=2)plt.title('Diff MACD for Tesla Prices')plt.xlabel('Date')plt.ylabel('Diff MACD')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (47)
  • When a new trend occurs, thefaster line(MACD Line) will react first and eventually cross theslower line(Signal Line).
  • The Mass Index (MI) indicator uses the high-low range to identify trend reversals based on range expansions. In this sense, the Mass Index is a volatility indicator that does not have a directional bias. Instead, the Mass Index identifies range bulges that can foreshadow a reversal of the current trend.
  • Strong increases in theMass Indexreadings may indicate the possibility of a trend-reversal in the near future.
  • Calculating and plotting the MI indicator
indicator_mi=ta.trend.MassIndex(high=data1["High"],low=data1["Low"])plt.figure(figsize=(10,6))plt.plot(indicator_ema.ema_indicator(), label='MI', color='red',lw=2)plt.title('Mass Index (MI) for Tesla Prices')plt.xlabel('Date')plt.ylabel('MI')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (48)
indicator_psar=ta.trend.PSARIndicator(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_psar.psar(), label='PSAR', color='green',lw=2)plt.plot(indicator_psar.psar_down(), label='PSAR Down', color='blue',lw=2)plt.plot(indicator_psar.psar_up(), label='PSAR Up', color='red',lw=2)plt.title('Parabolic Stop and Reverse (Parabolic SAR) for Tesla Prices')plt.xlabel('Date')plt.ylabel('PSAR')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (49)
  • Simple Moving Average (SMA) is one of the core indicators in technical analysis. It is simply the average price over the specifiedperiod.
  • Price crossing SMA is often used to trigger trading signals. When prices cross above the SMA, you might want to go long or cover short; when they cross below the SMA, you might want to go short or exit long.
  • Calculating and plotting the SMA indicator
indicator_sma=ta.trend.SMAIndicator(close=data1["Close"],window=20)plt.figure(figsize=(10,6))plt.plot(indicator_sma.sma_indicator(), label='SMA20', color='red',lw=2)indicator_sma=ta.trend.SMAIndicator(close=data1["Close"],window=50)plt.plot(indicator_sma.sma_indicator(), label='SMA50', color='blue',lw=2)plt.title('SMA for Tesla Prices')plt.xlabel('Date')plt.ylabel('SMA')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (50)
  • The weighted moving average (WMA) gives greater weight to recent data. This is in contrast to the simple moving average, which assigns equal weight to all data points.
  • Calculating and plotting the WMA indicator
indicator_wma=ta.trend.WMAIndicator(close=data1["Close"],window=20)plt.figure(figsize=(10,6))plt.plot(indicator_wma.wma(), label='WMA20', color='red',lw=2)indicator_wma=ta.trend.WMAIndicator(close=data1["Close"],window=50)plt.plot(indicator_wma.wma(), label='WMA50', color='blue',lw=2)plt.title('WMA - Weighted Moving Average Indicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('WMA')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (51)
  • The Schaff and Trend Cycle (STC)Indicator is one of the most vital tools in the toolkit of investors to predict the market trend and find the best entry and exit points.The STC indicator uses two thresholds of 25 and 75. If the STC indicator crosses the first threshold of 25, it generally indicates that the market is in an uptrend. If the STC indicator has breached the 75 level line, it generally indicates the strengthening of the trend in either of the two directions (high or low). When the STC indicator’s straight line is above 75, it is a signal for an overbought condition. On the other hand, if the straight line is below 25, it signals oversold stocks.
  • Calculating and plotting the STC indicator
indicator_stci=ta.trend.STCIndicator(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_stci.stc(), label='STC', color='red',lw=2)plt.title('Schaff Trend Cycle (STC) for Tesla Prices')plt.xlabel('Date')plt.ylabel('STC')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (52)
  • The triple exponential average (TRIX) shows the percentage change in a moving average that has been smoothed exponentially three times.The triple smoothing of moving averages is designed to filter out price movements that are considered insignificant or unimportant.
  • As with MACD, TRIX fluctuates above and below the zero line. A bullish crossover occurs when TRIX turns up and crosses above the signal line. A bearish crossover occurs when TRIX turns down and crosses below the signal line. Crossovers can last a few days or a few weeks, depending on the strength of the move.
  • Calculating and plotting the TRIX indicator
indicator_trix=ta.trend.TRIXIndicator(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_trix.trix(), label='TRIX', color='red',lw=2)plt.title('Trix (TRIX) Indicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('TRIX')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (53)
  • The Vortex Indicator (VI) plots two oscillating lines:one to identify positive trend movement and the other to identify negative price movement. Crosses between the lines trigger buy and sell signals that are designed to capture the most dynamic trending action, higher or lower. There’s no neutral setting for the indicator, which will always generate a bullish or bearish bias.
  • The two indicator lines provide valuable information on trends in the price of a stock. During periods of strongprice trends, the two indicator lines will move further apart. In contrast, indicator lines that move closer together indicate weak trends or periods of relative price stability.
  • Calculating and plotting the VI indicator
indicator_vi=ta.trend.VortexIndicator(high=data1["High"],low=data1["Low"],close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_vi.vortex_indicator_pos(), label='VI+', color='red',lw=2)plt.plot(indicator_vi.vortex_indicator_neg(), label='VI-', color='blue',lw=2)plt.title('Vortex Indicator (VI) for Tesla Prices')plt.xlabel('Date')plt.ylabel('VI')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (54)
  • Calculating and plotting the Diff VI = (VI+) – (VI-) indicator
plt.figure(figsize=(10,6))plt.plot(indicator_vi.vortex_indicator_diff(), label='Diff VI', color='red',lw=2)plt.title('Diff VI for Tesla Prices')plt.xlabel('Date')plt.ylabel('Diff VI')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (55)

Other Indicators

indicator_cumr=ta.others.CumulativeReturnIndicator(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_cumr.cumulative_return(), label='Cum Return', color='red',lw=2)plt.title('Cum Return for Tesla Prices')plt.xlabel('Date')plt.ylabel('Cum Return')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (56)
  • Cumulative returns are the total gains or losses of an investment over time. It is calculated by adding up the percentage returns of an investment over a specific period. Investors use cumulative returns to evaluate the performance of their investments over a given period. It is an essential metric as it provides insight into the overall success of an investment.
  • Daily log return, also known as natural log return, is a method of measuring the percentage change in the value of an investment over a period of one day. It is a widely used method in finance to measure the return of a financial asset such as a stock, bond or index.
  • Calculating and plotting DailyLogReturnIndicator for Tesla Prices
indicator_dayr=ta.others.DailyLogReturnIndicator(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_dayr.daily_log_return(), label='DailyLogReturnIndicator', color='red',lw=2)plt.title('DailyLogReturnIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('DailyLogReturn')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (57)
  • Daily return on a stock is used to measure the day to day performance of stocks, it isthe price of stocks at today’s closure compared to the price of the same stock at yesterday’s closure. Positive daily return means appreciation in stock price on daily comparison.
  • Calculating and plotting DailyReturnIndicator for Tesla Prices
indicator_dayr1=ta.others.DailyReturnIndicator(close=data1["Close"])plt.figure(figsize=(10,6))plt.plot(indicator_dayr1.daily_return(), label='DailyReturnIndicator', color='red',lw=2)plt.ylim(-15, 15) plt.title('DailyReturnIndicator for Tesla Prices')plt.xlabel('Date')plt.ylabel('DailyReturn')plt.legend()plt.grid(True)plt.show()
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (58)

Conclusions

  • Tesla (TSLA) is a leading electric vehicle (EV) manufacturer and clean energy company that has garnered significant attention from investors in recent years.
  • TSLA technical analysis is a popular method used by investors to analyze the stock’s price movements and identify potential trends.
  • We have performed a comprehensive real-time TSLA technical analysis using the TA-Lib Python library.
  • When conducting technical analysis on TSLA’s stock, we have considered a variety of factors, including the stock’s moving averages, trading volume, and support and resistance levels.
  • We have computed and plotted the following best performing technical indicators for TSLA prices:
  • Momentum indicators – RSI, StochRSI, KAMA, PPO, PVO, AO, ROC, SO, TSI, UO, and Williams %R;
  • Volume indicators – A/D, CMF, EOM, FI, MFI, NVI, OBV, VPT, and VWAP;
  • Volatility indicators – ATR, BB, the Donchian Channel, KC, UI;
  • Trend indicators – ADX, the Aroon indicator, CCI, DPO, EMA, the Ichimoku Cloud, KST, MACD, MI, PSAR, SMA, WMA, STC, TRIX, VI;
  • Other indicators – Cum Return and Daily Log Return.
  • Our recommendation is BUY consistent with the 3rd party technicals and the stock sentiment analysis.
  • Clearly, TSLA shares could reverse the long-term trend and finally turn bullish.
  • According to our analysis, TSLA is expected to rise more if it holds above $256.

Explore More

  • Real-Time Stock Sentiment Analysis w/ NLP Web Scraping
  • Plotly Dash TA Stock Market App
  • Advanced Integrated Data Visualization (AIDV) in Python – 1. Stock Technical Indicators
  • Quant Trading using Monte Carlo Predictions and 62 AI-Assisted Trading Technical Indicators (TTI)
  • Multiple-Criteria Technical Analysis of Blue Chips in Python
  • Predicting the JPM Stock Price and Breakouts with Auto ARIMA, FFT, LSTM and Technical Trading Indicators

Infographic

A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (59)
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (60)
A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (61)

Embed Socials

#trading #Python #Algorithms #investment $10k #ROI #blue #chip #StocksToBuy #StockToWatch @Meta @amazon @Tesla @ProcterGamble @jpmorgan @Apple #ExploreMore 👇
Multiple-Criteria Technical Analysis of Blue Chips in Pythonhttps://t.co/tpDPS30ZGl pic.twitter.com/elA6lAT6qz

— Alex Z. data4u #va #DataScience #investments (@AlexZaplin) October 2, 2023

Returns-Volatility Domain K-Means Clustering and LSTM Anomaly Detection of ALL S&P 500 Stocks#pythonprogramming #deeplearning #clusters
#StockMarket #ROI #InvestmentOpportunity #trading #ArtificialIntelligence @slashML #DataScience #ExploreMore 👇https://t.co/dddcuiNxpq pic.twitter.com/Kz6MmR3yWN

— Alex Z. data4u #va #DataScience #investments (@AlexZaplin) October 26, 2023

One-Time

Monthly

Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

€5.00

€15.00

€100.00

€5.00

€15.00

€100.00

€5.00

€15.00

€100.00

Or enter a custom amount

Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly

A Comprehensive Analysis of Best Trading Technical Indicators w/ TA-Lib – Tesla ’23 (2024)
Top Articles
Latest Posts
Article information

Author: Laurine Ryan

Last Updated:

Views: 5538

Rating: 4.7 / 5 (77 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Laurine Ryan

Birthday: 1994-12-23

Address: Suite 751 871 Lissette Throughway, West Kittie, NH 41603

Phone: +2366831109631

Job: Sales Producer

Hobby: Creative writing, Motor sports, Do it yourself, Skateboarding, Coffee roasting, Calligraphy, Stand-up comedy

Introduction: My name is Laurine Ryan, I am a adorable, fair, graceful, spotless, gorgeous, homely, cooperative person who loves writing and wants to share my knowledge and understanding with you.