True Strength Index Indicator with LightningChart JS Trader

Article

Assisted by AI

Learn how to integrate the True Strength Index Indicator into your trading applications with LightningChart JS Trader for advanced technical analysis.
Soroush Sohrabian

Ahmad Omid

Data Science Developer

LinkedIn icon
True-Strength-Index-Indicator-Cover

Introduction to the True Strength Index Indicator

The True Strength Index Indicator (TSI) is a technical analysis tool that helps traders identify trends, reversals, and overbought or oversold conditions in financial markets. Developed by William Blau, the TSI aims to smooth price changes over time, effectively filtering out market noise to provide a clearer trend direction.

The foundation of the True Strength Index Indicator lies in double smoothing price momentum, which helps traders better assess market dynamics. Unlike traditional momentum indicators, such as the Relative Strength Index (RSI) or Moving Average Convergence Divergence (MACD), the TSI emphasizes both trend strength and price momentum, making it a valuable addition to a trader’s technical toolbox.

How is the True Strength Index Indicator Used in Trading?

The True Strength Index Indicator is widely used in trading to:

  • Identify Market Trends: Traders use the TSI to determine whether a market is in an uptrend or downtrend based on the movement of the indicator relative to a zero line.
  • Spot Reversals: By analyzing crossovers between the TSI line and its signal line, traders can detect potential reversals in price movement.
  • Determine Overbought and Oversold Conditions: When the TSI reaches extreme values, it signals that an asset might be overbought (potential sell signal) or oversold (potential buy signal).

By incorporating the True Strength Index Indicator into a broader trading strategy, traders can improve their decision-making and optimize their entry and exit points.

Formula

The True Strength Index Indicator is calculated using the following steps:

1. Compute the price change:

PC = CCP – PCP

2. Apply an exponential moving average (EMA) for smoothing:

PCS = 25 period EMA of PC

3. Compute the double smoothed price change:

PCDS = 13 period EMA of PCS

4. Compute the absolute price change:

APC = AVCCP – PCP

5. Apply EMA to the absolute price change:

APCS = 25 period EMA of APC

6. Compute the double smoothed absolute price change:

APCDS = 13 period EMA of APCS

7. Finally, the True Strength Index (TSI) is computed as:

True-Strength-Index-Indicator-Formula

Where:

  • PC = Price Change
  • CCP = Current Close Price
  • PCP = Prior Close Price
  • PCS = PC Smoothed
  • EMA = Exponential Moving Average
  • PCDS = PC Double Smoothed
  • APC = Absolute PC
  • APCS = Absolute PC Smoothed
  • APCDS = Absolute PC Double Smoothed

Interpretation

  • TSI Above Zero: Indicates a bullish trend, where upward momentum is stronger than downward momentum.
  • TSI Below Zero: Suggests a bearish trend, with downward momentum prevailing.
  • Crossovers: When the TSI crosses above the signal line, it is considered a buy signal. Conversely, a crossover below the signal line suggests a sell signal.
  • Overbought/Oversold Levels: Extreme TSI values, such as above +25 or below -25, may indicate overbought or oversold conditions, signaling potential reversals.

Calculation Example

The computed values according to the given formula for each part as below:

True-Strength-Index-Indicator-Table

How to Create the Technical Indicator Using LC JS Trader

Step 1: Get LightningChart JS Trader

To begin, you’ll need access to LightningChart JS Trader. This library provides the tools necessary to create advanced technical indicators, including the True Strength Index Indicator. Visit the LightningChart JS Trader page to download the required components and review the documentation.

Step 2: Review the Interactive Example

LightningChart JS Trader includes interactive examples that demonstrate how to create custom technical indicators. Start by reviewing the documentation, focusing on how to integrate the True Strength Index Indicator into your chart setup. The interactive examples will guide you through the process of setting up the TSI Indicator, from importing the necessary modules to modify the chart settings.

Step 3: Code Explanation

In this step, we will break down the code that creates the chart with the True Strength Index Indicator, as shown in the image, using LightningChart JS Trader. The code demonstrates how to initialize a trading chart, apply the TSI Indicator, and customize its appearance.

True-Strength-Index-Indicator-Chart-Example

Here’s a detailed breakdown of each section:

A. Importing the Required Libraries:

   const lcjsTrader = require('@arction/lcjs-trader')
   const lcjs = require('@arction/lcjs')
   const { Themes } = lcjs
  • lcjsTrader: This library provides access to the LightningChart JS Trader functionalities, allowing you to create advanced financial charts.
  • lcjs: The main LightningChart JS library, used for general charting functionality.
  • Themes: A property within lcjs that provides access to pre-built themes. In this case, we are using the darkGold theme to style the chart.

B. Initializing the Trading Chart:

   lcjsTrader.trader(TRADER_LICENSE).then(async (trader) => {
    // Create a trading chart.
    const tradingChart = trader.tradingChart({ loadFromStorage: false, colorTheme: Themes.darkGold })
  • trader(TRADER_LICENSE): Initializes the LightningChart JS Trader with the provided license key (TRADER_LICENSE). This is required to access the charting functionalities for financial data.

Note you can request a LightningChart JS Trader trial license, which is free.

  • tradingChart(): This function creates a trading chart with certain options.
  • loadFromStorage: false: This disables the loading of previously stored chart data from local storage, ensuring a fresh chart setup.
  • colorTheme: Themes.darkGold: This applies the darkGold theme to the chart, which influences the background color, gridlines, and other visual elements.

C. Adding and Customizing the Indicator

    // Add a True Strength Index indicator 
    const tsi = tradingChart.indicators().addTrueStrengthIndex()
    tsi.setPeriodCounts(1, 25, 13, 13)
    tsi.setMovingAverageTypes(0, 0, 0)
    tsi.setSource(3)
    tsi.setLineColor('#32DCFF')
    tsi.setSignalColor('#A0FF46')
    tsi.setLineWidth(2)
  • addTrueStrengthIndex(): TSI double smoothens the price changes, thus filtering out the noise. TSI can be used to identify trends and reversals as well as to determine overbought and oversold conditions.
  • tsi.setPeriodCounts(1, 25, 13, 13): Sets the various time period counts used to calculate the indicator (pricePeriodCount, firstSmoothPeriods, doubleSmoothPeriods, signalPeriods).
  • **tsi.setMovingAverageTypes(0, 0, 0): Sets the types of the moving averages used to calculate the smoothings and the Signal line (firstSmoothMovingAverage, doubleSmoothMovingAverage, signalMovingAverage). In this case, 0 represents the Exponential Moving Average (EMA).
  • ***tsi.setSource(3): Sets which values the indicator calculations are based on. In this case, 3 represents the Close value.
  • tsi.setLineColor('#32DCFF): Sets the color of the True Strength Index line to a shade of blue.
  • tsi.setSignalColor('#A0FF46'): Sets the color of the Signal line to a shade of green.
  • tsi.setLineWidth(2): Sets the width of the oscillator and moving average lines to 2 pixels.

D. Loading Data from a CSV File

    // Reading data from a file.
    await fetch(`${document.head.baseURI}examples/assets/0000/Alphabet Inc (GOOGL).csv`).then((res) => res.text()).then((text) => {
        tradingChart.readCsvString(text, 'Alphabet Inc (GOOGL)')
    })
  • fetch(): This function retrieves a CSV file containing historical data for Alphabet Inc. (GOOGL). The CSV file includes pricing information for the company’s stock, which is plotted on the chart.
  • readCsvString(): This function reads the CSV data and interprets it as pricing data for Alphabet Inc. The second argument (‘Alphabet Inc (GOOGL)’) sets the label for the chart, as seen at the top of the chart image.

E. Setting the Currency for the Chart

    tradingChart.setCurrency('USD')
   })
  • setCurrency('USD'): This sets the currency of the chart to USD, ensuring that the pricing data is interpreted and displayed in US dollars.

** Enumeration of Moving Average Types in LC JS Trader:

  • Exponential Moving Average (EMA): 0
  • None: 1 (No moving average applied)
  • Simple Moving Average (SMA): 2
  • Time Series Moving Average (TSMA): 3
  • Triangular Moving Average (TMA): 4
  • Variable Moving Average (VMA): 5
  • Variable Index Dynamic Average (VIDYA): 6
  • Volume Weighted Moving Average (VWMA): 7
  • Weighted Moving Average (WMA): 8
  • Welles Wilder’s Smoothing (WWS): 9

** Enumeration Source in LC JS Trader: To select which values the indicator calculations are based on.

Rainbow-oscillator-Table

Advantages and Limitations of the Indicator

Advantages

  • Filters Out Noise: The double smoothing process reduces short-term price fluctuations, providing clearer trend signals.
  • Effective in Identifying Trends: The True Strength Index Indicator helps traders confirm whether an asset is in a bullish or bearish phase.
  • Reliable Overbought/Oversold Signals: Unlike simpler momentum indicators, TSI offers a more refined approach to spotting extreme price conditions.
  • Works Well with Other Indicators: TSI is often used alongside moving averages, MACD, and RSI to improve trading accuracy.

Limitations

  • Lagging Indicator: Due to its smoothing process, the TSI may react slower to sudden market movements, potentially causing delays in trade execution.
  • Not Always Accurate in Choppy Markets: The indicator may generate false signals in highly volatile or sideways markets.
  • Requires Proper Tuning: The effectiveness of the TSI depends on selecting appropriate smoothing periods for the asset being analyzed.

Conclusion

The True Strength Index Indicator is a powerful momentum-based tool that helps traders analyze market trends, detect reversals, and identify overbought or oversold conditions. By applying double smoothing, the TSI effectively reduces market noise and provides more reliable signals compared to traditional momentum indicators.

By utilizing the True Strength Index Indicator with LightningChart JS Trader, traders can visualize TSI calculations interactively and apply them to real-world trading scenarios. This powerful combination allows for enhanced technical analysis and improved decision-making.

Continue learning with LightningChart

JavaScript Data Visualization With LightningChart JS

JavaScript Data Visualization With LightningChart JS

Written by a human | Updated on April 9th, 2025LightningChart JS  LightningChart JS is the top contestant for next-generation JavaScript data visualization tools for web and mobile applications. From the start, it has been engineered to deal with maximum-size...

The Complete Guide to JavaScript Charts

The Complete Guide to JavaScript Charts

Written by a human | Updated on April 9th, 2025JavaScript Charting Libraries  Charting libraries are at a high peak and their development and usage are becoming even more popular in languages like JavaScript. As proof, there are a lot of JavaScript charting...

What Can Vibration Analysis Detect?

What Can Vibration Analysis Detect?

Written by a human | Updated on April 9th, 2025Vibration Charts  When you think about vibration analysis, what comes to mind? It is becoming a very common identification method in structural engineering to identify issues with potential structural integrity, such...