Logo
OFFLINEPIXEL
/ pinescript-strategies / pine-script-twiggs-money-flow

$ Pinescript Twiggs Money Flow

Unlock advanced volume-based Pinescript strategies with this comprehensive guide to Twiggs Money Flow in TradingView

500+ Clients Helped
100% Satisfaction
Live Trading Ready
⚠️
Trading financial markets carries risk. All content (PineScript code, indicators, strategies) on this website is for educational purposes only. Past performance is not indicative of future results. By using any code or information from this site, you agree that you are solely responsible for your trading decisions. The author disclaims all liability for any losses incurred. To gain from experts experiences, You can always try our Invite Only Scripts
01

Why Twiggs Money Flow Matters in Pinescript Strategies

Twiggs Money Flow (TMF) is a powerful volume-based indicator that helps traders gauge the strength of buying and selling pressure over time. By combining price and volume, TMF provides more nuanced signals than traditional oscillators, making it a valuable tool for Pinescript strategies focused on trend confirmation and reversal detection.

  • Identifies accumulation and distribution phases
  • Confirms trend strength and potential reversals
  • Filters out false breakouts using volume-weighted data
02

Basic Twiggs Money Flow Implementation in Pinescript

pine-script@terminal
//@version=5
indicator("Twiggs Money Flow", shorttitle="TMF", overlay=false)

// User inputs
length = input.int(21, title="TMF Length")

// Calculate the Money Flow Multiplier
mf_multiplier = ((close - low) - (high - close)) / (high - low)
mf_multiplier := na(mf_multiplier) ? 0 : mf_multiplier

// Money Flow Volume
mf_volume = mf_multiplier * volume

// Sum over the chosen period
sum_mf_volume = ta.sma(mf_volume, length)
sum_volume = ta.sma(volume, length)

// Twiggs Money Flow calculation
tmf = sum_mf_volume / sum_volume

plot(tmf, "Twiggs Money Flow", color=color.teal, style=plot.style_line)
hline(0, "Zero Line", color=color.gray)
$ ✓ Compiled successfully
03

Key Insight

Key Insight

Twiggs Money Flow oscillates above and below zero, signaling bullishness when positive and bearishness when negative. It is especially effective when combined with other Pinescript strategies for confirmation.

04

Twiggs Money Flow vs Classic Money Flow Index

While both TMF and MFI are volume-based, TMF uses a unique multiplier and smoothing, making it less sensitive to price spikes and better at highlighting sustained accumulation or distribution. For Pinescript strategies, TMF can offer clearer trend signals in choppy markets.

  1. Smoother signals: TMF reduces noise compared to MFI
  2. Better for trend trading: TMF highlights persistent buying/selling pressure
  3. Improved divergence detection: TMF can reveal hidden reversals
05

Advanced Pinescript Strategies Using Twiggs Money Flow

06

1. TMF Trend Confirmation Strategy

pine-script@terminal
//@version=5
strategy("TMF Trend Confirmation", overlay=true)

tmfLength = input.int(21, "TMF Length")
priceMA = input.int(50, "Price MA Length")

// Calculate TMF
mf_multiplier = ((close - low) - (high - close)) / (high - low)
mf_multiplier := na(mf_multiplier) ? 0 : mf_multiplier
mf_volume = mf_multiplier * volume
sum_mf_volume = ta.sma(mf_volume, tmfLength)
sum_volume = ta.sma(volume, tmfLength)
tmf = sum_mf_volume / sum_volume

// Price MA
ma = ta.sma(close, priceMA)

// Strategy logic
longCondition = close > ma and tmf > 0
shortCondition = close < ma and tmf < 0

if (longCondition)
    strategy.entry("Long", strategy.long)
if (shortCondition)
    strategy.entry("Short", strategy.short)
$ ✓ Compiled successfully
07

2. TMF Divergence Detection

pine-script@terminal
//@version=5
indicator("TMF Divergence Detector", overlay=true)

tmfLength = input.int(21, "TMF Length")
tmf = ta.sma(((close - low) - (high - close)) / (high - low) * volume, tmfLength) / ta.sma(volume, tmfLength)

// Detect price and TMF divergence
priceHigh = ta.highest(high, 14)
tmfHigh = ta.highest(tmf, 14)
bearDiv = high > high[1] and tmf < tmf[1] and tmf < 0
bullDiv = low < low[1] and tmf > tmf[1] and tmf > 0

plotshape(bearDiv, "Bearish Div", shape.triangledown, location.top, color.red)
plotshape(bullDiv, "Bullish Div", shape.triangleup, location.bottom, color.green)
$ ✓ Compiled successfully
08

Optimizing TMF for Your Pinescript Strategies

To maximize the impact of Twiggs Money Flow in your Pinescript strategies:

  • Combine with moving averages: Use TMF to confirm MA crossovers
  • Adjust length for your timeframe: Shorter periods for swing trading, longer for position trading
  • Filter signals: Add RSI or price action filters to reduce noise
09

Dynamic TMF Threshold Example

pine-script@terminal
//@version=5
indicator("Dynamic TMF Thresholds", overlay=false)
length = input.int(21, "TMF Length")
lookback = input.int(50, "Threshold Lookback")

mf_multiplier = ((close - low) - (high - close)) / (high - low)
mf_multiplier := na(mf_multiplier) ? 0 : mf_multiplier
mf_volume = mf_multiplier * volume

tmf = ta.sma(mf_volume, length) / ta.sma(volume, length)
upperBand = ta.percentile(tmf, lookback, 75)
lowerBand = ta.percentile(tmf, lookback, 25)

plot(tmf, "TMF", color=color.teal)
hline(upperBand, "Upper Band", color=color.red)
hline(lowerBand, "Lower Band", color=color.green)
hline(0, "Zero Line", color=color.gray)
$ ✓ Compiled successfully
10

Common TMF Pitfalls to Avoid in Pinescript Strategies

Warning: TMF can produce false signals in illiquid markets or during news events. Always use TMF as part of a broader Pinescript strategy, not in isolation.
  • Ignoring volume anomalies (e.g., earnings spikes)
  • Using TMF without price or trend confirmation
  • Overfitting TMF length to past data
11

Conclusion

Conclusion

Twiggs Money Flow is a robust volume-based indicator for Pinescript strategies, offering unique insights into accumulation and distribution. By integrating TMF with price action and other indicators, traders can build more reliable and adaptive Pinescript strategies for TradingView.

Enhance Your Trading

Get a high-performance Pinescript analysis tool for actionable market insights, designed for traders on the move.

This strategy runs in live mode on TradingView, helping you identify potential opportunities.

Get Pinescript Strategy