// Downloaded From https://www.WiseStockTrader.com
/*
Developed by Donald Dorsey, the Mass Index uses the high-low range to identify trend reversals based on range expansions. In this sense, the Mass Index is a volatility indicator that does not have a directional bias. Instead, the Mass Index identifies range bulges that can foreshadow a reversal of the current trend.

AFL by DQK 
*/

periods= Param("Periods", 14, 3, 200, 1);
smooth=  Param("Smooth", 7, 3, 200, 1);

function MI( Hi, Lo, periods, smooth )
{	M= EMA( Hi - Lo, smooth)/ EMA( EMA( Hi - Lo, smooth ), smooth );
return Sum( M, periods );
}

Hi= ( H + Max( C, O ) )/ 2;
Lo= ( L + Min( C, O ) )/ 2;

Plot( MI(H, L, periods, smooth), "Mass Index" + StrFormat("(%g,%g)", smooth, periods ), colorBrightGreen, styleLine|styleNoLabel );