Mass Index (MASSI)
Summary
Mass Index: Donald Dorsey's non-directional measure of how the trading range itself is expanding or contracting. The high-low range is smoothed by an exponential moving average, that average is smoothed again by a second one of the same length, and the ratio of the first to the second is summed over a trailing window.
Read it as a bulge detector, not a direction. A ratio above one means the range is widening faster than its own smoothing can absorb, so the sum rises; a narrowing range pulls it back down. Dorsey's own rule is the "reversal bulge": the index rising above 27, then falling back under 26.5, warns that the prevailing trend is about to reverse. Which way it reverses has to come from a trend indicator, because the Mass Index has no sign of its own.
Chart
Chart metadata i
Outputs
outReal:line·positive·levels: 26.5, 27
Formula
HL = high - low
single = EMA( HL, optInFastPeriod )
double = EMA( single, optInFastPeriod )
MASSI = SUM( single / double, optInSlowPeriod )
Both averages are the standard TA-Lib EMA: smoothing factor 2 / (optInFastPeriod + 1), seeded with the simple average of the first optInFastPeriod inputs of that stage.
Notes
- The two periods are not interchangeable and are never swapped:
optInFastPeriodis the length of both exponential averages,optInSlowPeriodthe length of the summation window. Some implementations reorder them when the summation window is the shorter of the two; this one does not. - A window in which every bar is exactly flat, high equal to low, leaves both averages at zero. The ratio is reported as 1 there, its continuous limit, so a flat market yields exactly
optInSlowPeriodrather than a spurious zero. - Implementations disagree on how the exponential averages are seeded. TA-Lib uses its own EMA convention, the simple average of the first
optInFastPeriodinputs, where Tulip Indicators, ta4j and trading-signals seed from a single raw value and converge to these values only after many bars. Published sample vectors, including the one in Achelis, are seeded that way and match only in the tail. - MASSI inherits EMA's unstable period rather than owning one, and inherits it twice: when
TA_FUNC_UNST_EMA, set to a count or to an Auto level, discardsubars from an EMA ofoptInFastPeriod, MASSI's first output moves by 2u.
Inputs
inHigh— High priceinLow— Low price
Outputs
outReal— Summed ratio of the two smoothed high-low ranges
Parameters
| Parameter | Type | Default | Accepted values | Description |
|---|---|---|---|---|
optInFastPeriod | integer | 9 | 2–100000 | Number of bars in each of the two exponential averages of the high-low range |
optInSlowPeriod | integer | 25 | 2–100000 | Number of bars the ratio is summed over |
Properties
Numerical Stability: Initial Unstable Period — Inherited from EMA, which MASSI computes internally; tunable via EMA's unstable period.
| ☐ Overlap Input |
| ✅ Independent Y-Axis i |
| ☐ Candlestick |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
| ☐ Input Must Be Positive |
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 out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_MASSI( 0, n - 1, high, low, 9, 25, &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 mut out = vec![0.0; 252];
let core = Core::new();
let range = core.massi(0, high.len() - 1, &high, &low, 9, 25, &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[] out = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.massi(0, high.length - 1, high, low, 9, 25, 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 outReal = new double[252];
var core = Core.Default;
OutRange r = core.Massi(0, high.Length - 1, high, low, 9, 25, outReal);
Console.WriteLine(FormattableString.Invariant($"{r.Count} values from bar {r.BegIdx}: [{outReal[0]:F4}, ..., {outReal[r.Count - 1]:F4}]"));import { massi } from 'ta-lib';
const high = new Float64Array(252); // your data, oldest first
const low = new Float64Array(252); // your data, oldest first
const { begIdx, values } = massi({ high, low }, {
fastPeriod: 9,
slowPeriod: 25,
});
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
out := make([]float64, 252)
core := talib.NewCore()
r, err := core.MASSI(0, len(high)-1, high, low, 9, 25, 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-python 0.8.1).
TA-Lib Definition: massi.c · massi.yaml
| Native | File |
|---|---|
| C | ta_MASSI.c |
| Rust | massi.rs |
| Java | Core_MASSI.java |
| C# | Core_MASSI.cs |
| TypeScript | massi.ts |
| Go | massi.go |
Python: talib.MASSI (ta-lib-python 0.8.1 or later), see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Mass Index, Dorsey Mass Index, Reversal Bulge
See Also
CVI · ATR · NATR · TRANGE · EMA · SUM
References
- Donald Dorsey, "The Mass Index", Technical Analysis of Stocks & Commodities, 1992 — the original description
- Steven B. Achelis, Technical Analysis from A to Z, McGraw-Hill, 2nd ed. (p. 182)
- StockCharts ChartSchool: Mass Index
- Tulip Indicators, mass — an independent implementation, differing in its seeding