Skip to main content

Module mfi

Module mfi 

Source
Expand description

§Money Flow Index (MFI)

Volume-weighted RSI-style oscillator on typical price:

TP = (H + L + C) / 3
raw money flow = TP * volume
+MF / −MF over period by TP direction vs prior TP
MFI = 100 − 100 / (1 + +MF/−MF)

Warm-up: needs period money-flow samples after the first bar (first TP has no prior). First MFI at index period (period flows from bars 1..=period).
If −MF = 0 and +MF > 0 → MFI = 100; if both zero → None.

Default: period 14 (MfiParams::period_14).


§Trading perspective

RegionHabit (classic)
MFI > 80“Overbought” with volume
MFI < 20“Oversold” with volume
Divergence vs priceVolume not confirming price extreme

§vs RSI / OBV

MFIRSIOBV
Uses volumeYes (× TP)NoYes (cumulative)
Bounded0–1000–100Unbounded
NarrativeMoney flow heatClose momentumFlow confirmation

Prefer MFI when volume quality matters for OB/OS; RSI when volume is noisy or missing; OBV for cumulative divergence without bounds.

§Pairs well with

  • Price oscillators (RSI/WillR) — agreement at extremes is stronger; disagreement is a flag.
  • VWAP — intraday location vs session VWAP + MFI.
  • ADX — high MFI in a strong ADX trend can stay elevated (trend, not auto-fade).

§Engineering

MfiParamsmfi / MfiStatemfi_solution. Batch via state. After warm-up each push is O(1) via rings of +MF/−MF contributions.

Structs§

MfiParams
MfiSeries
MfiSolution
MfiState
Incremental MFI.
ValidatedMfi

Functions§

mfi
mfi_solution
Examples