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.

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

na values in the source series are ignored.

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

Generate ta.mfi() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.mfi() and other built-in functions instantly.