• Detects bullish and bearish divergences between price action and the Money Flow Index (MFI).

    Divergences occur when price and the MFI indicator move in opposite directions, potentially signaling trend reversals:

    • Bullish divergence: Price makes lower lows while MFI makes higher lows
    • Bearish divergence: Price makes higher highs while MFI makes lower highs

    Parameters

    • candles: ICandle[]

      Array of candlestick data to analyze

    • zScoreConfig: IZScoreConfig = defaultZscoreConfig

      Z-Score configuration for peak detection. Defaults to:

      • lag: 3, threshold: 1, influence: 0.75
    • mfiPeriod: number = 14

      Period for MFI calculation (default: 14)

    Returns IDivergence[]

    Array of detected divergences with timing, strength, and description

    Example

    const zScoreConfig = { lag: 3, threshold: 1, influence: 0.75 };
    const mfiDivergences = Divergences.mfi(candles, zScoreConfig, 14);

    mfiDivergences.forEach(div => {
    console.log(`${div.type === SIGNAL_DIRECTION.BULLISH ? 'Bullish' : 'Bearish'} MFI divergence`);
    console.log(`Strength: ${div.strength} points`);
    console.log(`Duration: ${div.startTime} to ${div.endTime}`);
    });

Generated using TypeDoc