Formula and chart implementation of the Twiggs Money Flow indicator with LightningChart JS Trader technical analysis library.

Twiggs Money Flow Technical Analysis with LightningChart JS Trader

Article

Implement the Twiggs Money Flow indicator in your fintech software projects using LightningChart JS Trader.
Soroush Sohrabian

Ahmad Omid

Data Science Developer

LinkedIn icon
Twiggs-Money-Flow-Cover

Introduction to Twiggs Money Flow

The Twiggs Money Flow (TMF) is a technical analysis indicator that builds upon the Chaikin Money Flow (CMF). It refines the CMF by incorporating True Range instead of closing prices and leveraging Exponential Moving Averages (EMA) rather than cumulative volume sums. These adjustments make TMF a nuanced tool for evaluating bullish or bearish money flow trends and spotting potential breakouts in financial markets.

Origin and Development

Twiggs Money Flow was introduced by Colin Twiggs, a technical analyst renowned for advancing financial indicators. TMF was designed to address certain limitations of the Chaikin Money Flow indicator, particularly its sensitivity to sharp price changes and volume anomalies. By emphasizing True Range and smooth EMA calculations, TMF offers traders a clearer, more reliable picture of money flow dynamics.

How Is It Used in Trading?

TMF helps traders evaluate the strength of market trends and anticipate price breakouts by assessing the movement of capital in and out of an asset. When the TMF value is consistently positive, it suggests bullish money flow, while persistent negative values indicate bearish conditions. Traders use TMF to:

  • Confirm trend direction.
  • Identify potential reversals or breakouts.
  • Validate signals from other indicators for stronger technical setups.

Comparison of Twiggs Money Flow vs Chaikin Money Flow

While TMF and CMF serve a similar purpose, in measuring money flow, key differences set them apart. These differences make TMF better suited for traders who prioritize smoothing and stability over short-term volatility sensitivity.

Twiggs-Money-Flow-Comparison-Table

Formula

The Twiggs Money Flow formula integrates True Range and EMA to refine money flow calculations. The formula can be expressed as:

Twiggs-Money-Flow-Formula

Where:

  • Money Flow Volume is derived using price and volume data.
  • True Range adjusts for gaps and volatility, providing a more realistic range.
  • EMA ensures smoother trends and reduces false signals.

True Range Calculation

True Range (TR) is a critical component of the TMF, calculated as:

TR = max[(High − Low), ∣High − PreviousClose∣, ∣Low − PreviousClose∣]

This calculation ensures that the most significant price movements are captured, making the TMF more robust against erratic price shifts.

Interpretation

TMF values oscillate between -1 and +1, where:

  • +1 represents strong bullish money flow.
  • -1 indicates strong bearish money flow.
  • Values near zero suggest a neutral or indecisive market.

Key Components

  • True Range: Incorporates volatility for realistic movement measurement.
  • EMA: Provides smooth data trends for better long-term analysis.
  • Money Flow Volume: Links volume to price movement direction.

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 Twiggs Money Flow 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 Twiggs Money Flow Indicator into your chart setup. The interactive examples will guide you through the process of setting up the TMF 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 Twiggs Money Flow Indicator, as shown in the image, using LightningChart JS Trader. The code demonstrates how to initialize a trading chart, apply the TMF Indicator, and customize its appearance.

Twiggs-Money-Flow-Chart

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 Twiggs Money Flow indicator
    const tmf = tradingChart.indicators().addTwiggsMoneyFlow()
    tmf.setPeriodCount(21)
    tmf.setLineColor('#FFF833')
    tmf.setLineWidth(3)
  • addTwiggsMoneyFlow(): TMF is a variation of Chaikin Money Flow indicator using True Range instead of Close Location Value and moving averages instead of cumulative volume. Can be used to evaluate money flow as bullish or bearish, and to warn of breakouts.
  • tmf.setPeriodCount (21): Sets the period count to 21 days. This defines the number of periods used in the calculation of the TMF indicator, affecting its sensitivity and smoothing.
  • tmf.setLineColor('# FFF833'): Changes the color of the TMF line to yellow. This enhances the visual distinction of the indicator on the chart.
  • tmf.setLineWidth(3): Sets the line thickness of TMF to 3 pixels. This makes the line more prominent and easier to observe during analysis.

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.

Advantages and Limitations of the Indicator

Advantages

One of the key advantages of the Twiggs Money Flow (TMF) indicator is its enhanced accuracy in measuring market sentiment and money flow. By incorporating True Range into its calculation, TMF accounts for price gaps and volatility, which are often overlooked by other indicators such as the Chaikin Money Flow (CMF).

This makes TMF particularly effective in markets with frequent price gaps or during periods of high volatility, ensuring that significant movements are not ignored. Furthermore, the use of the Exponential Moving Average (EMA) provides a smoothing effect, reducing the noise from short-term fluctuations and allowing traders to focus on meaningful trends.

Another notable strength of TMF is its versatility. It can be used in various trading scenarios, such as confirming existing trends, identifying potential breakouts, or validating signals from other technical indicators. TMF’s ability to oscillate between -1 and +1 gives traders a clear visual representation of bullish or bearish conditions, making it easier to integrate into broader trading strategies.

Additionally, the emphasis on volume-weighted price movements ensures that periods of significant trading activity are adequately reflected in the analysis, providing a more comprehensive view of market dynamics.

Limitations

Despite its strengths, the TMF indicator is not without limitations. One of its primary drawbacks is the relative complexity of its calculation compared to simpler indicators like the CMF. Traders need to understand the components of True Range, Money Flow Volume, and EMA, which can be challenging for beginners. This complexity might deter less experienced traders from using the indicator effectively.

Another limitation is the lagging nature of the TMF due to its reliance on EMA. While EMA smooths out data and reduces noise, it also introduces a slight delay in signal generation. In fast-moving markets, this lag can result in missed opportunities or delayed responses to sudden trend changes.

Additionally, the indicator’s dependence on accurate and reliable volume data can be a disadvantage in markets where volume data is incomplete, manipulated, or less significant, such as some forex markets.

Conclusion

The Twiggs Money Flow (TMF) is a powerful variation of the Chaikin Money Flow indicator, incorporating True Range and EMA for a smoother, more accurate evaluation of money flow. It excels in identifying bullish and bearish trends and warning of potential breakouts. However, like all technical tools, it is best used alongside other indicators to confirm signals and build robust trading strategies.

By integrating TMF into their analyses, traders can achieve greater precision in evaluating market conditions and improving their decision-making processes. By using LightningChart JS Trader, traders can visualize and customize TMF calculations to gain actionable insights efficiently.

Continue learning with LightningChart

Data Visualization Template for Electron JS | LightningChart®

Updated on April 4th, 2025 | Written by humanAre you already building cross-platform applications with Electron JS?  In some of our previous articles, we’ve worked on TypeScript projects where we created pie charts and vibration chart applications. And as we...

Bar chart race JavaScript

Bar chart race JavaScript

Updated on April 14th, 2025 | Written by humanBar chart race JavaScript  When I wrote this article, the COVID-19 pandemic was at its peak point. Today, things are much better thanks to vaccinations that continued their steady positive global effect. With this bar...

A brief look into ‘performance’ in Web Data Visualization

A brief look into ‘performance’ in Web Data Visualization  Introduction  Throughout the existence of humankind, we’ve been trying to present data in various visual forms. Therefore, it is quite accurate to say that the concept of data visualization is...