Momentum OscillatorsPine Script v6

ta.mfi()Money Flow Index

The Money Flow Index (MFI) is a technical oscillator that uses price and volume data for identifying overbought or oversold signals in an asset. It is also known as volume-weighted RSI.

TradingView language reference

Syntax

Syntax
ta.mfi(series, length) → series float

Arguments

ParameterTypeDescription
seriesseries int/floatTypical price series (commonly hlc3) for money flow.
lengthseries intLookback length for positive and negative money flow sums.

Returns

Money Flow Index.

Remarks

The built-in ignores na source observations. MFI also uses chart volume; missing volume or a zero flow denominator needs attention in a custom calculation. Money flow here is a price-volume proxy, not identified cash transfers or trader positions.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.mfi")
plot(ta.mfi(hlc3, 14))

// same on pine
pine_mfi(src, length) =>
    float upper = math.sum(volume * (ta.change(src) <= 0 ? 0 : src), length)
    float lower = math.sum(volume * (ta.change(src) >= 0 ? 0 : src), length)
    100.0 - (100.0 / (1.0 + upper / lower))
plot(pine_mfi(hlc3, 14))

Trading Applications

Identify overbought (>80) and oversold (<20) conditions with volume confirmation

Detect divergences between price and money flow

Confirm breakouts with volume-weighted momentum

Use as a volume-enhanced alternative to RSI

Related Functions

Frequently Asked Questions

ta.mfi() returns the Money Flow Index: a 0–100 oscillator that weights price movement by volume to gauge buying vs selling pressure over length bars.

RSI uses price gains/losses only. MFI incorporates volume in its money-flow terms, so it emphasizes periods where price moves occur with heavier participation.

Common references are 80/20, similar in spirit to RSI 70/30 but not identical. Adjust to liquidity and timeframe.

Generate ta.mfi() Code with AI

Draft Pine Script using ta.mfi() with Pineify's AI Coding Agent, then review the arguments and test the result on your chart. Usage depends on your plan and available credits.