Main Page > Articles > Money Flow Index > Twiggs Money Flow: A Quantitative Approach with NumPy and SciPy

Twiggs Money Flow: A Quantitative Approach with NumPy and SciPy

From TradingHabits, the trading encyclopedia · 5 min read · February 28, 2026
The Black Book of Day Trading Strategies
Free Book

The Black Book of Day Trading Strategies

1,000 complete strategies · 31 chapters · Full trade plans

Introduction to Twiggs Money Flow

Twiggs Money Flow is a volume-weighted indicator that is used to measure buying and selling pressure over a given period. It was developed by Colin Twiggs and is similar to the Chaikin Money Flow, but with a few key differences. Twiggs Money Flow is used to confirm trends, to spot divergences, and to generate trading signals.

This article will explore the calculation and interpretation of Twiggs Money Flow, its implementation using NumPy, and how to apply SciPy for a more rigorous statistical analysis of this insightful indicator.

The Mathematical Formulation of Twiggs Money Flow

Twiggs Money Flow is calculated in several steps:

  1. True Range: First, calculate the True Range for each period:

    True Range = max(High, Yesterday's Close) - min(Low, Yesterday's Close)
    
  2. Value: Then, calculate the Value for each period:

    Value = ((Close - min(Low, Yesterday's Close)) - (max(High, Yesterday's Close) - Close)) / True Range
    
  3. Money Flow: Next, calculate the Money Flow for each period:

    Money Flow = Value * Volume
    
  4. Twiggs Money Flow: Finally, calculate Twiggs Money Flow as the ratio of the exponential moving averages (EMAs) of the positive and negative Money Flow:

    TMF = EMA(Positive Money Flow, n) / EMA(Total Money Flow, n)
    

    Where 'n' is the number of periods, typically 21.

Implementing Twiggs Money Flow with NumPy

NumPy's array operations can be used to efficiently calculate Twiggs Money Flow. The following Python function demonstrates this:

python
import numpy as np

def calculate_twiggs_money_flow(high, low, close, volume, n=21):
    # This is a simplified implementation for demonstration purposes
    true_range = np.maximum(high, np.roll(close, 1)) - np.minimum(low, np.roll(close, 1))
    value = ((close - np.minimum(low, np.roll(close, 1))) - (np.maximum(high, np.roll(close, 1)) - close)) / true_range
    money_flow = value * volume
    
    positive_money_flow = np.where(money_flow > 0, money_flow, 0)
    total_money_flow = np.abs(money_flow)
    
    ema_positive_mf = np.convolve(positive_money_flow, np.ones(n)/n, mode='valid')
    ema_total_mf = np.convolve(total_money_flow, np.ones(n)/n, mode='valid')
    
    tmf = ema_positive_mf / ema_total_mf
    
    return tmf

Statistical Analysis of Twiggs Money Flow with SciPy

We can use SciPy to analyze the statistical properties of Twiggs Money Flow. For example, we can use the percentileofscore function from scipy.stats to determine the percentile rank of a given Twiggs Money Flow value. This can help in identifying extreme readings.

python
from scipy.stats import percentileofscore

# Assuming 'tmf_data' is a NumPy array of Twiggs Money Flow values
percentile = percentileofscore(tmf_data, 0.5)

Sample Data and Twiggs Money Flow Calculation

Due to the complexity of the Twiggs Money Flow calculation, a simplified table is provided below:

DayTwiggs Money Flow
210.65
220.68
230.71
240.69
250.66

Actionable Trading Examples

  1. Trend Confirmation: A Twiggs Money Flow value above 0.5 indicates buying pressure, while a value below 0.5 indicates selling pressure. A rising Twiggs Money Flow confirms an uptrend, while a falling Twiggs Money Flow confirms a downtrend.

  2. Divergences: Divergences between Twiggs Money Flow and the price can be effective signals. A bullish divergence occurs when the price makes a new low, but Twiggs Money Flow makes a higher low. A bearish divergence occurs when the price makes a new high, but Twiggs Money Flow makes a lower high.

Conclusion

Twiggs Money Flow is a sophisticated volume-weighted indicator that can provide valuable insights into buying and selling pressure. By using NumPy for efficient calculation and SciPy for statistical analysis, traders can develop a deeper understanding of Twiggs Money Flow and incorporate it into their quantitative trading strategies.