Volume

Money Flow Index Buy Sell Signals - TradingView Guide

Check MFI threshold crossings and confirmed-pivot divergence. Read the money-flow formula, missing-volume rules and a closed-bar Pine Script example.

Money Flow Index Signal Interpretation

Quick-reference guide to 5 signal types you will see on the chart.

Signal TypeIndicator ConditionMarket MeaningInterpretation limits
Cross above lower thresholdMFI moves from at or below 20 to above 20 at bar close.The oscillator left its lower zone.Does not identify institutions or prove selling exhaustion.
Cross below upper thresholdMFI moves from at or above 80 to below 80 at bar close.The oscillator left its upper zone.Can precede renewed strength rather than a reversal.
Regular bullish divergenceA confirmed price pivot low is lower, but MFI sampled at that pivot is higher than at the preceding low.Price and the flow-ratio oscillator disagree.Two-bar pivot delay; not an independently confirmed MFI pivot.
Regular bearish divergenceA confirmed price pivot high is higher, but sampled MFI is lower.Price rose while the sampled ratio weakened.No measured reliability score is supplied.
Unavailable flowMissing or invalid inputs in the window, or no positive/negative classified flow.The example suppresses the MFI value.Unavailable is not a neutral reading or a trade signal.

Money Flow Index Pine Script Signal Code

Educational indicator example. Review its exact rules and compare its plots with your intended calculation in TradingView. It does not place orders or establish profitability.

Pine Script v6
//@version=6
indicator("MFI Threshold and Pivot Conditions", overlay=false)
length = input.int(14, "MFI Period", minval=1)
upper = input.int(80, "Upper Threshold", minval=51, maxval=100)
lower = input.int(20, "Lower Threshold", minval=0, maxval=49)
source = input.source(hlc3, "Source")
validBar = not na(source) and not na(source[1]) and source > 0 and source[1] > 0 and not na(volume) and volume >= 0
validCount = math.sum(validBar ? 1.0 : 0.0, length)
rawFlow = source * volume
positiveFlow = validBar and source > source[1] ? rawFlow : 0.0
negativeFlow = validBar and source < source[1] ? rawFlow : 0.0
positiveSum = math.sum(positiveFlow, length)
negativeSum = math.sum(negativeFlow, length)
totalFlow = positiveSum + negativeSum
// Equivalent ratio form; one-sided positive flow reaches 100, not 99.01.
mfi = validCount == length and totalFlow > 0 ? 100 * positiveSum / totalFlow : na
crossUp = ta.crossover(mfi, lower)
crossDown = ta.crossunder(mfi, upper)
exitLower = barstate.isconfirmed and crossUp
exitUpper = barstate.isconfirmed and crossDown

priceLow = ta.pivotlow(low, 2, 2)
priceHigh = ta.pivothigh(high, 2, 2)
newLow = not na(priceLow)
newHigh = not na(priceHigh)
priorLow = ta.valuewhen(newLow, priceLow, 1)
priorLowMfi = ta.valuewhen(newLow, mfi[2], 1)
priorHigh = ta.valuewhen(newHigh, priceHigh, 1)
priorHighMfi = ta.valuewhen(newHigh, mfi[2], 1)
bullDiv = barstate.isconfirmed and newLow and not na(priorLowMfi) and priceLow < priorLow and mfi[2] > priorLowMfi
bearDiv = barstate.isconfirmed and newHigh and not na(priorHighMfi) and priceHigh > priorHigh and mfi[2] < priorHighMfi
plot(mfi, "MFI", color=color.blue, linewidth=2)
hline(upper, "Upper", color=color.red)
hline(50, "Midpoint", color=color.gray)
hline(lower, "Lower", color=color.green)
plotshape(exitLower, "Exit lower zone", shape.triangleup, location.bottom, color=color.green, size=size.tiny)
plotshape(exitUpper, "Exit upper zone", shape.triangledown, location.top, color=color.red, size=size.tiny)
// Pivot markers stay on the confirmation bar.
plotshape(bullDiv, "Bullish divergence confirmed", shape.labelup, location.bottom, color=color.aqua, text="DIV", size=size.tiny)
plotshape(bearDiv, "Bearish divergence confirmed", shape.labeldown, location.top, color=color.orange, text="DIV", size=size.tiny)
alertcondition(exitLower, "MFI exits lower zone", "MFI crossed above the configured lower threshold at bar close")
alertcondition(exitUpper, "MFI exits upper zone", "MFI crossed below the configured upper threshold at bar close")
alertcondition(bullDiv, "MFI bullish divergence", "Price-pivot bullish MFI divergence confirmed two bars after pivot")
alertcondition(bearDiv, "MFI bearish divergence", "Price-pivot bearish MFI divergence confirmed two bars after pivot")

Example settings for Money Flow Index

Record the inputs used by the example. These settings are not an optimized trading recommendation.

Feature comparison table: Default vs Description
ParameterDefaultDescription
MFI Period14Number of bars in positive and negative raw-flow sums. The example requires valid price and volume across the entire window.
SourceHLC3Default typical price is (high + low + close) / 3. A source change changes both raw flow and its up/down classification.
Upper Threshold80Illustrative upper boundary. Crossing below it is an event, not a calibrated sell recommendation.
Lower Threshold20Illustrative lower boundary. Crossing above it does not establish a price bottom.
Pivot left/right bars2 / 2Fixed price-pivot confirmation lengths. MFI is sampled on each price pivot bar.

Turn the condition into an explicit rule

Specify the calculation, confirmation time, entry and exit rules before asking Pineify to draft or revise Pine Script. Review the code and simulate realistic costs before evaluating a strategy.

Explore Pine Script coding

FAQ

Money Flow Index Signals FAQ

How is MFI calculated, and how does it differ from RSI?
MFI classifies typical-price times volume by whether typical price rose or fell, then compares positive and negative sums. It does not multiply price change by volume. RSI instead smooths price gains and losses. Neither identifies who traded, so an MFI change is not proof of institutional accumulation or distribution.
What happens when negative flow is zero?
In this example, positive flow with no negative flow produces 100; negative flow with no positive flow produces 0. If both are zero, the result is unavailable. As a hypothetical check, positive flow 300 and negative flow 100 produce 100 x 300 / 400 = 75.
Does this script detect failure swings?
No. It implements threshold crossings and price-pivot divergence. A bullish MFI failure swing requires leaving the lower zone, pulling back while remaining above it, then breaking the intervening MFI high. That multi-step sequence needs its own state tracking; a single crossover is insufficient.
When are the divergence signals known?
The newer price pivot needs two subsequent bars. The marker appears when the second right-side bar closes and compares MFI on the two price-pivot bars. It is not placed back on the earlier pivot, and the example does not require MFI itself to form a separate pivot or be outside 20/80.
Can volume quality change the result?
Yes. Missing volume suppresses this example over the affected lookback. Tick volume and exchange-specific crypto volume represent different activity from consolidated traded volume. Large observations also change the rolling sums; compare the exact feed and sessions before evaluating a rule.
Does closed-bar confirmation make a profitable strategy?
No. It prevents this example from triggering during a still-open bar, but it supplies no entry, exit, fill, cost or performance model. Use the named TradingView alert conditions at bar close, recreate alerts after changing the saved configuration, and evaluate any separately defined strategy on data not used to choose its settings.