Market Facilitation Index (MARKETFI)
Summary
Bill Williams' Market Facilitation Index (Trading Chaos, 1995): the price range a bar travelled per unit of volume traded — how much movement the market "facilitated" per tick. A rising index on rising volume is read as a move the market is absorbing; a rising index on falling volume as one it is not.
Retail material commonly abbreviates this "MFI" or "BW MFI". TA-Lib already ships TA_MFI for the Money Flow Index, so this carries the MARKETFI name used by Tulip and pandas-ta-classic.
Charting packages often overlay a four-state colour code (green / fade / fake / squat) derived from the signs of the bar-to-bar change in this index and in volume. That is an interpretive layer on top of the series, not part of it; outReal is the scalar only.
Chart
Chart metadata i
Inputs
inHigh:positive·negative·zeroinLow:positive·negative·zeroinVolume:positive·zero
Outputs
outReal:line·zero·positive
Formula
MARKETFI_t = (high_t - low_t) / volume_t
A bar with zero volume reports 0 rather than dividing: it facilitated no movement.
Inputs
inHigh— High price of each barinLow— Low price of each barinVolume— Volume of each bar
Outputs
outReal— Range travelled per unit of volume, per bar
Properties
Numerical Stability: Start-Independent
| ☐ Overlap Input |
| ✅ Independent Y-Axis i |
| ☐ Candlestick |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
Example
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double high[252]; /* your data, oldest first */
double low[252]; /* your data, oldest first */
double volume[252]; /* your data, oldest first */
double out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_MARKETFI( 0, n - 1, high, low, volume, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d: [%.4f, ..., %.4f]\n", outNBElement, outBegIdx, out[0], out[outNBElement - 1] );use ta_lib::Core;
let high = vec![0.0; 252]; // your data, oldest first
let low = vec![0.0; 252]; // your data, oldest first
let volume = vec![0.0; 252]; // your data, oldest first
let mut out = vec![0.0; 252];
let core = Core::new();
let range = core.marketfi(0, high.len() - 1, &high, &low, &volume, &mut out)?;
println!("{} values from bar {}: [{:.4}, ..., {:.4}]", range.count, range.beg_idx, out[0], out[range.count - 1]);import io.github.talib.Core;
import io.github.talib.OutRange;
import java.util.Locale;
double[] high = new double[252]; // your data, oldest first
double[] low = new double[252]; // your data, oldest first
double[] volume = new double[252]; // your data, oldest first
double[] out = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.marketfi(0, high.length - 1, high, low, volume, out);
System.out.printf(Locale.ROOT, "%d values from bar %d: [%.4f, ..., %.4f]%n", r.count(), r.begIdx(), out[0], out[r.count() - 1]);using System;
using TALib;
var high = new double[252]; // your data, oldest first
var low = new double[252]; // your data, oldest first
var volume = new double[252]; // your data, oldest first
var outReal = new double[252];
var core = Core.Default;
OutRange r = core.Marketfi(0, high.Length - 1, high, low, volume, outReal);
Console.WriteLine(FormattableString.Invariant($"{r.Count} values from bar {r.BegIdx}: [{outReal[0]:F4}, ..., {outReal[r.Count - 1]:F4}]"));import { marketfi } from 'ta-lib';
const high = new Float64Array(252); // your data, oldest first
const low = new Float64Array(252); // your data, oldest first
const volume = new Float64Array(252); // your data, oldest first
const { begIdx, values } = marketfi({ high, low, volume });
console.log(values.length + ' values from bar ' + begIdx + ': [' + values[0]?.toFixed(4) + ', ..., ' + values[values.length - 1]?.toFixed(4) + ']');import (
"fmt"
"log"
talib "ta-lib.github.io/go"
)
high := make([]float64, 252) // your data, oldest first
low := make([]float64, 252) // your data, oldest first
volume := make([]float64, 252) // your data, oldest first
out := make([]float64, 252)
core := talib.NewCore()
r, err := core.MARKETFI(0, len(high)-1, high, low, volume, out)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d values from bar %d: [%.4f, ..., %.4f]\n", r.NBElement, r.BegIdx, out[0], out[r.NBElement-1])Implementation
Added in 0.8.1.
TA-Lib Definition: marketfi.c · marketfi.yaml
| Native | File |
|---|---|
| C | ta_MARKETFI.c |
| Rust | marketfi.rs |
| Java | Core_MARKETFI.java |
| C# | Core_MARKETFI.cs |
| TypeScript | marketfi.ts |
| Go | marketfi.go |
Python: talib.MARKETFI, see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
See Also
References
- Bill Williams, Trading Chaos, 1995, introduces the Market Facilitation Index as the price range a bar travelled per unit of volume.
- Tulip Indicators
ti_marketfiand pandas-ta-classicmarketficompute the same form, but divide unconditionally: both emit ±Inf on a zero-volume bar where this returns 0. - The four-state green/fade/fake/squat colour code charting packages overlay is derived from the signs of the bar-to-bar change in this index and in volume. It is an interpretive layer, not part of the series;
outRealis the scalar only.