Market Facilitation Index Pine Script — Complete TradingView Guide
The Market Facilitation Index (BW MFI) is a volume-efficiency indicator developed by Bill Williams that classifies each price bar into one of four color-coded states — Green, Blue, Gray, or Red — by comparing the rate of change in price spread (high − low) / volume with the rate of change in volume. Green bars confirm strong trending moves; Red "Squat" bars signal volume absorption and potential reversals; Blue "Fade" bars reveal market exhaustion; Gray "Fake" bars expose low-conviction breakouts. The Market Facilitation Index Pine Script implementation provided here plots color-coded dots directly on the price chart, making it immediately usable on stocks, crypto, and futures across 15-minute to Daily timeframes. This complete guide covers the BW MFI formula, all four bar states, parameter tuning, three concrete trading strategies, and a step-by-step walkthrough for generating a customised version using Pineify.
What Is the Market Facilitation Index?
The Market Facilitation Index (BW MFI) is a volume-efficiency oscillator that measures how effectively the market is moving price per unit of volume, used to classify bar quality and identify high-probability trend continuation or reversal setups. It was developed by Bill Williams and first published in his 1995 book Trading Chaos. Unlike conventional oscillators that output a bounded numeric reading, the BW MFI communicates through four discrete bar states encoded as colors — making it a qualitative, pattern-based indicator rather than a threshold-based one.
The core formula measures the rate of change of two quantities. First, the price spread efficiency: r_hl = ta.roc((high − low) / volume, 1), where high − low is the bar range and volume is the bar's total traded contracts or shares. Second, volume momentum: r_v = ta.roc(volume, 1). The four bar states emerge from the sign combinations of these two rate-of-change values:
- Green (Trending): r_hl > 0 AND r_v > 0 — spread efficiency rising, volume rising. Market is actively facilitating movement; trend continuation is likely.
- Blue (Fade): r_hl < 0 AND r_v < 0 — spread efficiency falling, volume falling. Market disinterest; price may stall or consolidate.
- Gray (Fake): r_hl > 0 AND r_v < 0 — spread efficiency rising without volume support. Price is moving, but volume does not confirm — a classic false breakout warning.
- Red (Squat): r_hl < 0 AND r_v > 0 — heavy volume is absorbed with little price progress. A battle between buyers and sellers that often precedes a sharp reversal or breakout in the direction of the next Green bar.
Bill Williams designed the BW MFI as part of his broader Chaos Trading system, which includes the Awesome Oscillator, Alligator, and Accelerator Oscillator. The BW MFI is intended to be used as a bar-by-bar confirmation filter: Green bars validate entries in the trend direction; Squat bars warn traders to tighten stops or reduce size.
The Market Facilitation Index is most effective in markets with accurate exchange volume data: US equities, equity futures (ES, NQ, RTY), and spot or perpetual crypto on major centralised exchanges (BTC/USDT, ETH/USDT). Forex spot markets only have tick volume as a proxy, which significantly reduces the indicator's reliability. Optimal timeframes are 15m to Daily. On 1m–5m charts, a single block trade can spike the volume reading and generate a Squat or Green classification that is not representative of broader market behavior.
Best Markets
Stocks · Crypto · Futures
Best Timeframes
15m, 1H, 4H, Daily
Bar States
Green · Blue · Gray · Red
Market Facilitation Index Pine Script Code
The code below computes the Market Facilitation Index using ta.roc((high - low) / volume, 1) and ta.roc(volume, 1), classifies each bar into one of four states, and plots a color-coded dot on the overlay chart just below each bar's low. To add it to TradingView, open the Pine Script editor with Alt+P, paste the code, and click Add to chart. The colored dots appear directly on the price pane without requiring a separate indicator panel.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Pineify
//@version=6
indicator(title="Market Facilitation Index", overlay=true, max_labels_count=500)
p_ta_market_facilitation_index(series float offset) =>
r_hl = ta.roc((high - low) / volume, 1)
r_v = ta.roc(volume, 1)
green_f = (r_hl > 0) and (r_v > 0)
fade_f = (r_hl < 0) and (r_v < 0)
fake_f = (r_hl > 0) and (r_v < 0)
squat_f = (r_hl < 0) and (r_v > 0)
mfi = low - (low * offset)
[mfi, green_f, fade_f, fake_f, squat_f]
[p_ind_1_mfi, p_ind_1_greenBar, p_ind_1_fadeBar, p_ind_1_fakeBar, p_ind_1_squatBar] = p_ta_market_facilitation_index(0.005)
// MFI color logic: Green = rising MFI + rising volume, Blue = falling both,
// Gray = rising MFI + falling volume, Red = falling MFI + rising volume
p_ind_1_mfi_color = p_ind_1_greenBar ? color.rgb(76, 175, 80, 0) :
p_ind_1_fadeBar ? color.rgb(33, 150, 243, 0) :
p_ind_1_fakeBar ? color.rgb(158, 158, 158, 0) :
p_ind_1_squatBar ? color.rgb(244, 67, 54, 0) : na
plot(p_ind_1_mfi, title="MFI", color=p_ind_1_mfi_color, style=plot.style_circles, linewidth=4)Chart Preview

Market Facilitation Index Parameters
| Parameter | Default Value | Description | Recommended Range |
|---|---|---|---|
| offset | 0.005 | Fractional offset applied to the dot plot position: mfi = low - (low × offset). Shifts the colored dot slightly below each bar's low so it is visible without overlapping the candlestick body. | 0.001–0.02 depending on asset price |
| r_hl ROC period | 1 | The lookback period for ta.roc((high - low) / volume, 1). A period of 1 compares the current bar's spread efficiency directly with the previous bar. The original Bill Williams formula uses 1. | 1 (standard) — do not change |
| r_v ROC period | 1 | The lookback period for ta.roc(volume, 1). Compares current bar volume to the previous bar. Using 1 gives the most sensitive bar-by-bar classification. Increasing this smooths signals but is not standard BW practice. | 1 (standard) — do not change |
| plot style | plot.style_circles | The visual style of the MFI dots. Default is filled circles (plot.style_circles) with linewidth 4. Change to plot.style_columns for a histogram view. | circles (default) or columns |
Tuning Guide by Trading Style
- Scalping (1m–5m, stocks/crypto): increase offset to 0.01–0.02 on volatile assets to prevent dots from overlapping wicks
- Day trading (15m–1H, futures): default offset 0.005 works well for ES and NQ futures; adjust for high-priced indices
- Swing trading (4H–Daily, equities): default offset is sufficient; combine with Alligator and Awesome Oscillator per Bill Williams' Chaos system
Trading Strategies Using the Market Facilitation Index
The Market Facilitation Index generates the most reliable signals when used as a bar-quality filter combined with a trend indicator. Below are three concrete strategies with specific entry and exit conditions.
Strategy 1 — Green Bar Trend Continuation
Market environment: established trend · Best timeframe: 1H, 4H
Enter trend-following positions only on Green bars, which confirm that both spread and volume support the move. Pair the BW MFI with a ta.ema(close, 21) to filter trades in the trend direction only.
- Confirm trend: close > EMA(21) for long bias, close < EMA(21) for short bias
- Wait for a Green bar:
r_hl > 0 and r_v > 0 - Long entry: open of the next bar after a Green bar in an uptrend (close > EMA(21))
- Stop loss: below the low of the Green bar
- Exit: first Blue (Fade) bar, or when close crosses below EMA(21)
Strategy 2 — Squat Bar Reversal Setup
Market environment: trend nearing exhaustion · Best timeframe: 4H, Daily
A Red Squat bar signals that volume is building without price progress — a battleground bar. The breakout direction of the next bar reveals the winner. Combine with ta.rsi(close, 14) to confirm momentum at the potential reversal point.
- Identify a Squat bar:
r_hl < 0 and r_v > 0 - Check RSI(14) for overbought/oversold: RSI > 65 for potential short; RSI < 35 for potential long
- Long entry: Squat bar followed by a Green bar, AND RSI < 35 at the Squat close
- Short entry: Squat bar followed by a Blue or Red bar with a lower close, AND RSI > 65
- Stop loss: 1 ATR(14) beyond the Squat bar's range; Target: 2:1 reward-to-risk ratio
Strategy 3 — Fake Bar Breakout Filter
Market environment: breakout scenario · Best timeframe: 15m, 1H
Gray Fake bars flag breakouts that lack volume confirmation, helping traders avoid entering on false moves. Combine with a 20-period Bollinger Bands breakout setup to filter for genuine volume-backed expansions vs. volume-empty spikes.
- Detect a price breakout above the Bollinger upper band:
close > ta.bb(close, 20, 2).upper - Check MFI bar state: if Gray (Fake), skip the trade — breakout is low-conviction
- Enter only if the breakout bar is Green (spread up + volume up), confirming institutional participation
- Stop loss: back inside the Bollinger Band (close below upper band)
- Exit: first Fake or Fade bar on the continuation, or when price returns to the 20-period Bollinger midline
Disclaimer: The strategies above are for educational purposes only and do not constitute investment advice. Past performance does not guarantee future results. Always apply proper risk management and position sizing.
How to Generate the Market Facilitation Index in Pineify
- 1
Open Pineify
Go to pineify.app and sign in — a free account gives you instant access to all indicator generators, including the Market Facilitation Index builder.
- 2
Click "New Indicator"
Select "Indicator" as the script type from the creation menu. Pineify starts with a clean Pine Script v6 template ready for your configuration.
- 3
Describe the Market Facilitation Index configuration you need
Type a prompt such as: "Add a Market Facilitation Index with Green/Blue/Gray/Red bar coloring, an offset of 0.005, and add alerts when a Squat bar is detected." Pineify's AI Coding Agent generates the complete code in seconds.
- 4
Copy the generated code to TradingView
Click "Copy to TradingView" to copy the code, then paste it into the Pine Script editor in TradingView (Alt+P) and click "Add to chart". The color-coded dots appear on the overlay immediately.
- 5
Adjust the offset parameter in the indicator settings
Open the indicator settings panel in TradingView to change the plot offset — increase it on higher-priced instruments so the dots clear the wicks. No code editing is required.
Frequently Asked Questions
Related Pine Script Indicators
Build Your Market Facilitation Index Indicator in Seconds
Skip the manual coding. Pineify's AI Coding Agent generates complete, ready-to-use Pine Script indicators — including the BW MFI with Squat alerts and custom color themes — instantly for free.
Try Pineify Free