Indicator · Pine Script v4 · Own pane

Money Flow Index

by everget

Calculates the standard Money Flow Index (MFI) oscillator alongside an exponential moving average signal line in a separate pane.

View on GitHub

GitHub stars948on the repository
Pine versionv4older, still runs
Lines of code55
Settings12inputs
LicenceGPL-3.0
Last update10 days ago18 Oct 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

55 lines of Pine Script v4 from oscillators/mfi_money_flow_index.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

mfi_money_flow_index.pine
//@version=4
// Copyright (c) 2021-present, Alex Orekhov (everget)
// Money Flow Index script may be freely distributed under the terms of GPL-3.0 license.
study("Money Flow Index", shorttitle="MFI", precision=2)

length = input(title="Length", type=input.integer, defval=14, minval=1)
signalLength = input(title="Signal Length", type=input.integer, defval=9, minval=1)
src = input(title="Source", type=input.source, defval=hlc3)
obLevel = input(title="Overbought Level", type=input.integer, defval=80)
osLevel = input(title="Oversold Level", type=input.integer, defval=20)
maxLevel = input(title="Max Level", type=input.integer, defval=100)
minLevel = input(title="Min Level", type=input.integer, defval=0)
showHistogram = input(title="Show Histogram ?", type=input.bool, defval=false)
highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=input.bool, defval=true)
highlightCrossovers = input(title="Highlight MFI/Signal Crossovers ?", type=input.bool, defval=true)
highlightMiddleCrossovers = input(title="Highlight Middle Line Crossovers ?", type=input.bool, defval=true)
applyRibbonFilling = input(title="Apply Ribbon Filling ?", type=input.bool, defval=true)

mfi = mfi(src, length)
signal = ema(mfi, signalLength)

trendColor = mfi > signal ? #0ebb23 : color.red
smiColor = applyRibbonFilling ? trendColor : #ff3e7d
signalColor = applyRibbonFilling ? trendColor : #3c78d8

mfiPlot = plot(mfi, title="MFI", color=smiColor, transp=0)
signalPlot = plot(signal, title="Signal", color=signalColor, transp=0)

hist = mfi - signal
histColor = hist >= 0 ? hist[1] < hist ? #26A69A : #B2DFDB : hist[1] < hist ? #FFCDD2 : #EF5350
plot(showHistogram ? hist : na, title="Histogram", style=plot.style_columns, color=histColor, transp=0)

var color noneColor = color.new(color.white, 100)

maxLevelPlot = hline(maxLevel, title="Max Level", linestyle=hline.style_dotted, color=noneColor)
obLevelPlot = hline(obLevel, title="Overbought Level", linestyle=hline.style_dotted, color=#00796b)
hline(50, title="Middle Level", linestyle=hline.style_dotted, color=#989898)
osLevelPlot = hline(osLevel, title="Oversold Level", linestyle=hline.style_dotted, color=#f57f17)
minLevelPlot = hline(minLevel, title="Min Level", linestyle=hline.style_dotted, color=noneColor)
fill(obLevelPlot, osLevelPlot, title="Middle Zone", color=color.purple, transp=95)

obFillColor = mfi > obLevel and highlightBreakouts ? color.green : noneColor
osFillColor = mfi < osLevel and highlightBreakouts ? color.red : noneColor

fill(maxLevelPlot, obLevelPlot, title="Overbought Level Breakout", color=obFillColor, transp=85)
fill(minLevelPlot, osLevelPlot, title="Oversold Level Breakout", color=osFillColor, transp=85)

fillColor = applyRibbonFilling ? trendColor : noneColor
fill(mfiPlot, signalPlot, title="Ribbon", color=fillColor, transp=70)

middleCrossBgColor = highlightMiddleCrossovers ? mfi > 50 ? color.green : color.red : noneColor
bgcolor(middleCrossBgColor, title="Middle Line Crossover Background", transp=90)

plotshape(highlightCrossovers and crossover(mfi, signal) ? mfi : na, title="MFI/Signal Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)
plotshape(highlightCrossovers and crossunder(mfi, signal) ? mfi : na, title="MFI/Signal Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)

Overview

The script visually highlights trend conditions through dynamic ribbon filling, optional difference histogram bars, and overbought or oversold breakout fills. It also plots circle shapes upon MFI and signal line crossovers and provides optional background coloring based on whether the MFI is above or below the 50 middle level. Key settings include calculation lengths, source price, and customizable threshold levels.

Details

Published by

everget on GitHub

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum, Volume

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.

Topics

pinepinescripttechnical-indicatorsindicatorsoscillatorbandsaveragetradingviewindicatormoving-average

Settings

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

SettingTypeDefaultVariable
Lengthint14length
Signal Lengthint9signalLength
Sourcesourcehlc3src
Overbought Levelint80obLevel
Oversold Levelint20osLevel
Max Levelint100maxLevel
Min Levelint0minLevel
Show Histogram ?boolfalseshowHistogram
Highlight Overbought/Oversold Breakouts ?booltruehighlightBreakouts
Highlight MFI/Signal Crossovers ?booltruehighlightCrossovers
Highlight Middle Line Crossovers ?booltruehighlightMiddleCrossovers
Apply Ribbon Filling ?booltrueapplyRibbonFilling
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

Commitment Gauge

by harryguiacorn
219 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 4 days ago · GPL-3.0 GitHub repository of Chaikin Oscillator

Volume Flow Analysis

by iamrichardD
57 stars

This indicator calculates volume moving averages, volume spikes, and price-volume momentum to detect institutional order flow. It plots in a separate pane and generates visual signals for high-volume activity and flow persistence. Key inputs adjust the volume

Indicator v6 VolumeScalping
Updated 1 year ago · Apache-2.0 GitHub repository of Volume Flow Analysis

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers