Triple Exponential Average (TRIX) Indicator for Trading App Development

Article

Assisted by AI

Learn how to integrate the triple exponential average (TRIX) indicator in your financial and trading applications using LightningChart JS Trader.
Soroush Sohrabian

Ahmad Omid

Data Science Developer

LinkedIn icon
Triple-Exponential-Average-Cover

Introduction

The Triple Exponential Average (TRIX) is a powerful momentum indicator used by traders to identify market trends, filter out insignificant price fluctuations, and detect potential reversals. Originally developed by Jack Hutson in the 1980s, the TRIX indicator aims to smooth out price data using a triple-smoothed exponential moving average and present it as a percentage change. Its main purpose is to eliminate market noise and highlight true directional movement.

In practice, the Triple Exponential Average stands out for its ability to respond quickly to meaningful shifts in price while ignoring minor corrections and market jitters. This makes it especially useful for trend-following strategies, where clean signals are essential. The indicator is plotted as a line on a separate chart panel and typically oscillates above and below a zero line, much like other momentum-based indicators.

Formula

The Triple Exponential Average formula involves applying three exponential moving averages (EMAs) consecutively. The period used in LCJS Trader is 14, although this can be adjusted based on strategy.

  • EMA1 = EMA of closing prices over n periods
  • EMA2 = EMA of EMA1 over n periods
  • EMA3 = EMA of EMA2 over n periods
  • TRIX:
Triple-Exponential-Average-Formula

Interpretation:

  • A positive TRIX value (above 0) indicates upward momentum.
  • A negative TRIX value (below 0) suggests downward momentum.
  • Crossovers above or below the zero line are common signals used for entry/exit.
  • A signal line (typically a simple or exponential moving average of TRIX itself) can be added for crossover strategies.

The triple smoothing drastically reduces noise, making the Triple Exponential Average useful for capturing dominant trends, especially in longer timeframes.

Calculation Example

Assume the following:

  • n = 14 (periods for each EMA)
  • We already have:
    • EMA1 values calculated from closing prices
    • EMA2 values calculated from EMA1
    • EMA3 values calculated from EMA2

Now suppose:

  • EMA3 (Yesterday) = 104.
  • EMA3 (Today) = 105.04

Apply the TRIX formula:

Triple-Exponential-Average-Calculation

On the chart, this TRIX value would plot slightly above the zero line, indicating positive momentum and possibly a continuation of an uptrend.

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 specialized library contains all the necessary components for developing advanced technical indicators, including the Triple Exponential Average (TRIX) 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. These examples do more than just explain; they show you what works in practice. Start with the documentation, focusing on how to add the TRIX indicator to your chart. The interactive examples take you through each step of the process, from importing the right modules to adjusting your chart settings for the best display.

Step 3: Code Explanation

In this step, we’ll examine the code that creates the chart with the TRIX indicator, as shown in the image, using LightningChart JS Trader. The code reveals how to properly initialize a trading chart, apply the indicator, and customize its visual properties to enhance your technical analysis. Understanding these code components helps you see how the different parts work together to produce an effective analysis tool. This knowledge allows you to adapt the implementation for your specific trading requirements.

Triple-Exponential-Average-Chart

Here’s a detailed breakdown of each section:

A. Importing the Required Libraries:

const lcjsTrader = require('@lightningchart/lcjs-trader')
const lcjs = require('@lightningchart/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.

B. Initializing the Trading Chart:

   lcjsTrader.trader(TRADER_LICENSE).then(async (trader) => {
     // Create a trading chart. Optionally, various chart settings can be provided.
     const tradingChart = trader.tradingChart({ loadFromStorage: false })
  • 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.

C. Adding and Customizing the Indicator

    // Add a Triple Exponential Average indicator 
    const trix = tradingChart.indicators().addTripleExponentialAverage()
    trix.setPeriodCount(14)
    trix.setSource(3)
    trix.setLineColor('#FBFF14')
    trix.setSignalColor('#28B1CC')
    trix.setLineWidth(3)
  • addTripleExponentialAverage(): TRIX is a triple exponentially smoothed moving average shown as a percentage change. It is designed to filter out unimportant price changes.
  • setPeriodCount(14): Sets the number of time periods (n) used to calculate the indicator.
  • ** trix.setSource(3): Sets which values the indicator calculations are based on. In this case, calculations based on Close values.
  • setLineColor('#FBFF14'): Sets the color of the TRIX line to yellow.
  • setSignalColor('#28B1CC'): Sets the color of the TRIX line to blue.
  • setLineWidth(3): Sets the lines width of the indicator to 3 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 Source in LC JS Trader:

To select which values the indicator calculations are based on.

Trade-Volume-Index-Table-Enumeration-Source

Advantages and Limitations of the Indicator

Advantages:

  • Smooths Noise: Triple smoothing reduces reaction to minor fluctuations.
  • Zero-Centered for Clarity: Easier to interpret trend direction.
  • Momentum + Trend: TRIX can act both as a momentum oscillator and trend filter.
  • Works Across Timeframes: From intraday charts to long-term analysis.

Limitations:

  • Lagging Nature: TRIX is slower to react to sudden changes due to triple smoothing.
  • False Signals in Sideways Markets: Choppy conditions can cause whipsaws.
  • Needs Confirmation: Best paired with other indicators or volume data for confirmation.

Conclusion

The Triple Exponential Average is a clean, trend-focused indicator that delivers actionable insights by filtering out market noise. Its triple-smoothing process and zero-centered scale make it a go-to tool for traders who value clarity and momentum precision.

In LightningChart JS Trader, implementing TRIX is straightforward and efficient. The LCJS Trader API supports high-performance charting, allowing for interactive, real-time visualization of the Triple Exponential Average and its signals. To explore the TRIX indicator in practice, check out the LCJS Trader Interactive Examples and bring your trading analysis to the next level.

Continue learning with LightningChart