Indicator · Pine Script v6 · Own pane

Money Flow Index

by TamTH-Dev· code credited to tamth_

This indicator calculates and plots multi-timeframe Money Flow Index (MFI) values in a separate pane.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code84
Settings6inputs
LicenceNone statedfile: MPL-2.0
Last update6 weeks ago18 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

84 lines of Pine Script v6 from strategies/strategies3/Money Flow Index.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Money Flow Index.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tamth_
 
//@version=6
indicator(title = "Money Flow Index", shorttitle = "MFI", format = format.price, precision = 2)

//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
// Colors
color TRANSPARENT_COLOR = color.new(#000000, 100)
color WHITE_COLOR       = #dee2e6
color BLACK_COLOR       = #000000
color RED_COLOR         = #F72585
color ORANGE_COLOR      = #fb5607
color YELLOW_COLOR      = #ffbe0b
color GREEN_COLOR       = #2a9d8f
color AQUA_COLOR        = #4CC9F0
color BLUE_COLOR        = #4361ee
color PURPLE_COLOR      = #3F37C9
color PINK_COLOR        = #B5179E
color LIGHT_GRAY_COLOR  = #364156
color DARK_GRAY_COLOR   = #212d40
color TEXT_COLOR        = #ced4da

//-----------------------------------------------------------------------------
// Common Variables
//-----------------------------------------------------------------------------
series int barIdx = bar_index

//-----------------------------------------------------------------------------
// Common Methods
//-----------------------------------------------------------------------------
debug(simple string txt) =>
    var label lbl = label.new(barIdx, na, txt, xloc.bar_index, yloc.price, color(na), label.style_none, WHITE_COLOR, size.large, text.align_left)
    label.set_xy(lbl, barIdx, ta.highest(10)[1])
    label.set_text(lbl, txt)

getDefHtf() =>
    switch timeframe.period
        "1"   => "15"
        "3"   => "30"
        "5"   => "60"
        "15"  => "240"
        "30"  => "480"
        "60"  => "D"
        "240" => "W"
        "1D"  => "M"
        "1M"  => "12M"
        => timeframe.period

//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// Money Flow Index
//-----------------------------------------------------------------------------
// Settings
//-----------------------------------------------------------------------------
mfiGrp = "Money Flow Index"
fastMfiShowed = input.bool(true, title = "Fast MFI", group = mfiGrp, inline = "fastMfi")
fastMfiLen    = input.int(14, title = "", minval = 1, group = mfiGrp, inline = "fastMfi")
fastMfiTf     = input.timeframe("", title = "", group = mfiGrp, inline = "fastMfi")
slowMfiShowed = input.bool(true, title = "Slow MFI", group = mfiGrp, inline = "slowMfi")
slowMfiLen    = input.int(14, title = "", minval = 1, group = mfiGrp, inline = "slowMfi")
slowMfiTf     = input.timeframe("", title = "", group = mfiGrp, inline = "slowMfi")

//-----------------------------------------------------------------------------
// Calculate
//-----------------------------------------------------------------------------
fastMfi = request.security(syminfo.tickerid, fastMfiTf, ta.mfi(hlc3, fastMfiLen), barmerge.gaps_on)
slowMfi = request.security(syminfo.tickerid, slowMfiTf != "" ? slowMfiTf : getDefHtf(), ta.mfi(hlc3, slowMfiLen), gaps = barmerge.gaps_on)

//-----------------------------------------------------------------------------
// Render
//-----------------------------------------------------------------------------
plot(fastMfiShowed ? fastMfi : na, "Fast MFI", color = AQUA_COLOR, display = display.pane)
plot(slowMfiShowed ? slowMfi : na, "Slow MFI", color = PURPLE_COLOR, display = display.pane)
overbought = hline(80, title = "Overbought", color = TRANSPARENT_COLOR)
oversold = hline(20, title = "Oversold", color = TRANSPARENT_COLOR)
fill(overbought, oversold, color = color.new(PURPLE_COLOR, 90), title = "Main Zone")
hline(50, "Middle Line", color = color.new(PINK_COLOR, 70), linestyle = hline.style_solid)

//-----------------------------------------------------------------------------

Overview

Money Flow Index features two distinct MFI lines: a fast MFI based on the current or custom timeframe, and a slow MFI using a higher timeframe or automatic step-up timeframe logic. Users can independently enable or disable visibility, adjust length periods, and set specific custom timeframes for both fast and slow MFI calculations to evaluate volume-weighted momentum across multiple horizons.

Details

Published by

TamTH-Dev on GitHub

Code credit

tamth_, as written in the script's header

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Fast MFIbooltruefastMfiShowed
fastMfiLenint14fastMfiLen
fastMfiTftimeframefastMfiTf
Slow MFIbooltrueslowMfiShowed
slowMfiLenint14slowMfiLen
slowMfiTftimeframeslowMfiTf
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Money Flow Index

by everget
947 stars

Calculates the standard Money Flow Index (MFI) oscillator alongside an exponential moving average signal line in a separate pane. The script visually highlights trend conditions through dynamic ribbon filling, optional difference histogram bars, and overbought

Indicator v4 Oscillators & momentumVolume
Updated 12 days ago · GPL-3.0 GitHub repository of Money Flow Index

Commitment Gauge

by harryguiacorn
220 stars

This indicator measures directional momentum by evaluating candlestick body proportions and volume over a user-defined lookback window. It computes the ratio of candle body to total range, weights the cumulative value by volume and absolute body size, and dete

Indicator v4 VolumeCandlestick patterns
Updated 1 year ago · None stated GitHub repository of Commitment Gauge

Aggregate Signal

by capissimo
114 stars

This indicator builds an aggregate oscillator in a separate pane. It scales open, high, low, close, and volume into a 0 to 1 range, then averages scaled readings from MACD, a MACD histogram, RSI, stochastic, CCI, momentum, OBV, a directional index, volume-weig

Indicator v4 Oscillators & momentumVolume Repaints
Updated 1 year ago · None stated GitHub repository of Aggregate Signal

This indicator calculates the Bill Williams Market Facilitation Index as the high-low range divided by volume, or zero when volume is zero. It compares the index and volume with the previous bar and assigns one of four zones: green for both rising, fade for bo

Indicator v6 VolumeOscillators & momentum
Updated 4 weeks ago · Apache-2.0 GitHub repository of Bill Williams Market Facilitation Index

PPO ATR Bands

by cryptorife
75 stars

PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l

Indicator v4 Oscillators & momentumMoving averages
Updated 3 years ago · GPL-3.0 GitHub repository of PPO ATR Bands

Chaikin Oscillator

by be-thomas
65 stars

Calculates the Chaikin Oscillator by taking the difference between a fast exponential moving average and a slow exponential moving average of the Accumulation/Distribution line. It plots the resulting line in a separate pane alongside a dashed zero reference l

Indicator v4 Oscillators & momentumVolume
Updated 6 days ago · GPL-3.0 GitHub repository of Chaikin Oscillator

More Oscillators & momentum scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers