Money Flow Index
Install and import#
npm install fintech-algorithmsimport { moneyFlowIndex } from "fintech-algorithms/technical-indicators/volume-indicators/money-flow-index";Signature#
moneyFlowIndex(high, low, close, volume, p)RSI computed on typical price weighted by volume — commonly described as volume-weighted RSI, and read on the same 0–100 scale.
Parameters#
| Name | Type | Notes |
|---|---|---|
high | number[] | Per-bar high prices, chronological. |
low | number[] | Per-bar low prices, chronological. |
close | number[] | Per-bar closing prices, chronological. |
volume | number[] | Per-bar traded volume, aligned index-for-index with the price series. |
p | number | Lookback in bars. min: 1 · integer: true |
Returns#
Record<string, (number | null)[]> · length same-as-input
Parallel series: typical_price, raw_money_flow, positive_flow, negative_flow, money_flow_ratio and mfi.
Warm-up#
The first p positions are null. One extra bar is needed beyond the window, because the first bar has no prior typical price to compare against.
Errors#
- When p < 1 or is not an integer — throws RangeError
- When the input series are not all the same length — throws RangeError
Complexity: time O(n),
space O(n).
Worked example#
executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.
Input#
[101.05, 101.52482, 102.098461, 102.729464, 103.36806, 103.963227]Showing 6 of 120 elements.
[99.4, 99.462904, 99.936275, 100.512674, 101.151059, 101.802588]Showing 6 of 120 elements.
[100.28, 100.686113, 101.200346, 101.789282, 102.408843, 103.010585]Showing 6 of 120 elements.
[990000, 1066468.036, 1130033.236, 1170141.961, 1180511.26, 1160272.794]Showing 6 of 120 elements.
Call#
moneyFlowIndex(high, low, close, volume, p)Returns#
object with 6 fields: typical_price, raw_money_flow, positive_flow, negative_flow, money_flow_ratio, mfi
{
"typical_price": [
100.24333333333334,
100.55794566666668,
101.07836066666668,
101.67714000000001,
102.30932066666666,
102.92546666666668
],
"raw_money_flow": [
99240900,
107241834.81932473,
114221906.99372847,
118976687.98847154,
120777305.0499507,
119421618.78308721
],
"positive_flow": [null, null, null, null, null, null],
"negative_flow": [null, null, null, null, null, null],
"money_flow_ratio": [null, null, null, null, null, null],
"mfi": [null, null, null, null, null, null]
}Other exports#
This module also exports
obv, accumulationDistributionLine, chaikinMoneyFlow, volumePriceTrend, forceIndex. Every module additionally exports run as an alias of its
primary function, and a meta object carrying its catalog id, domain, family,
shape and article URL.
Diagrams#
Calculation flow#
Calculation flow
flowchart LR
A["Finalized finalized high, low, close, and nonnegative volume"] --> B["Validate order, alignment, and finite values"]
B --> C["Typical price"]
C --> D["Raw and directional flow"]
D --> E["Positive / negative sums"]
E --> F{"History and denominator valid?"}
F -- "No · short history" --> G["warming-up + reason"]
F -- "No · no finite scale" --> H["undefined + reason"]
F -- "Yes" --> I["Money Flow Index"]
I --> J["ready + aligned component trace"]
Data-basis reconciliation — Money Flow Index
flowchart LR
A["Same instrument and identifier?"] -->|Yes| B["Same venue or consolidated scope?"]
A -->|No| X["Stop: different measurement"]
B -->|Yes| C["Same volume unit and bar interval?"]
B -->|No| X
C -->|Yes| D["Same session and close policy?"]
C -->|No| X
D -->|Yes| E["Same corrections and price-volume adjustment basis?"]
D -->|No| X
E -->|Yes| F["Same MFI convention, seed, warm-up, and precision?"]
E -->|No| X
F -->|Yes| G["Compare intermediate components"]
F -->|No| Y["Document convention difference"]
G --> H["Compare final output"]
How it works#
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References#
- Money Flow (MFI) — TradingView
- Volume — TradingView
- TA-Lib function API and volume indicators — TA-Lib
- Consolidated Tape — U.S. Securities and Exchange Commission, Investor.gov
- Closing Price — U.S. Securities and Exchange Commission, Investor.gov
- What is Volume? — CME Group
- TA-Lib momentum indicator functions — TA-Lib
- Claim-role ledger
- Evidence boundary
- Enhanced claim-to-source map
- Public evidence boundary