• Calculate Money Flow Index (MFI) for a series of candles.

    The Money Flow Index is a momentum oscillator that uses both price and volume to measure buying and selling pressure. It's often called the "Volume RSI" because it incorporates volume into the RSI formula.

    The MFI oscillates between 0 and 100:

    • Values above 80 typically indicate overbought conditions
    • Values below 20 typically indicate oversold conditions
    • Values above 50 suggest buying pressure dominates
    • Values below 50 suggest selling pressure dominates

    Parameters

    • candles: ICandle[]

      Array of candlestick data to analyze

    • period: number = 14

      Period for MFI calculation (default: 14)

    • precision: number = 2

      Number of decimal places for rounding (default: 2)

    • useRollingWindow: boolean = true

      Use O(N) rolling window optimization vs O(N*period) (default: true)

    Returns (number | null)[]

    Array of MFI values (same length as input, with null for insufficient data)

    Example

    import * as ta from 'chart-patterns';

    const mfiValues = ta.MFI.calculateMFI(candles, 14);
    console.log('Latest MFI:', mfiValues[mfiValues.length - 1]);

    // Check for overbought/oversold conditions
    const latestMFI = mfiValues[mfiValues.length - 1];
    if (latestMFI && latestMFI > 80) {
    console.log('Overbought condition detected');
    } else if (latestMFI && latestMFI < 20) {
    console.log('Oversold condition detected');
    }

Generated using TypeDoc