Money Flow Index (MFI)
Created by Quong and Soudack, the Money Flow Index is a price-volume oscillator that shows buying and selling momentum. Values outside of the 80 / 20 thresholds are considered overbought / oversold. [Discuss] 💬
// C# usage syntax
IReadOnlyList<MfiResult> results =
bars.ToMfi(lookbackPeriods);Parameters
| param | type | description |
|---|---|---|
lookbackPeriods | int | Number of periods (N) in the lookback period. Must be greater than 1. Default is 14. |
Historical price bars requirements
You must have at least N+1 historical price bars to cover the warmup periods.
bars is a collection of generic TBar historical price bars. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.
Response
IReadOnlyList<MfiResult>- This method returns a time series of all available indicator values for the
barsprovided. - It always returns the same number of elements as there are in the historical price bars.
- It does not return a single incremental indicator value.
- The first
Nperiods will havenullMFI values since they cannot be calculated.
MfiResult
| property | type | description |
|---|---|---|
Timestamp | DateTime | Date from evaluated TBar |
Mfi | double | Money Flow Index |
Utilities
See Utilities and helpers for more information.
Streaming
Use the buffer-style List<T> when you need incremental calculations without a hub:
MfiList mfiList = new(lookbackPeriods);
foreach (IBar bar in bars) // simulating stream
{
mfiList.Add(bar);
}
// based on `ICollection<MfiResult>`
IReadOnlyList<MfiResult> results = mfiList;Subscribe to a BarHub for advanced streaming scenarios:
BarHub barHub = new();
MfiHub observer = barHub.ToMfiHub(lookbackPeriods);
foreach (IBar bar in bars) // simulating stream
{
barHub.Add(bar);
}
IReadOnlyList<MfiResult> results = observer.Results;See Buffer lists and Stream hubs for full usage guides.
Chaining
Results can be further processed on Mfi with additional chain-enabled indicators.
// example
var results = bars
.ToMfi(..)
.ToRsi(..);This indicator must be generated from bars and cannot be generated from results of another chain-enabled indicator or method.
See Chaining indicators for more.