// Make the number of periods configurable. mfperiods = INPUT("MFI Periods", 14, 1, 100); // Net money flow for this period. mf = TYP * V; // Aggregate the net money flow over the user-specified number of periods. posmf = SUM(IF(TYP > TYP[-1], mf, 0), mfperiods); negmf = SUM(IF(TYP < TYP[-1], mf, 0), mfperiods); // Compute the money flow index for this period, taking care not to divide by zero. mfi = IF( negmf = 0, IF(posmf = 0, 50, 100), 100 - 100 / (1 + posmf / negmf)); // Plot the money flow as a wavecrest centered at 50 with overbought and oversold levels at 80 and 20. PLOT_WAVECREST(mfi, 50, 70, 30, 1, Color.Brown, Color.Brown); SUMMARY("MFI({?}) {?:F2}", mfperiods, mfi);