• Detects bullish and bearish divergences between price action and the Relative Strength Index (RSI).

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

    • Bullish divergence: Price makes lower lows while RSI makes higher lows
    • Bearish divergence: Price makes higher highs while RSI 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
    • rsiPeriod: number = 14

      Period for RSI 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 rsiDivergences = Divergences.rsi(candles, zScoreConfig, 14);

    rsiDivergences.forEach(div => {
    console.log(`${div.type === SIGNAL_DIRECTION.BULLISH ? 'Bullish' : 'Bearish'} RSI divergence`);
    console.log(`Description: ${div.description}`);
    });

Generated using TypeDoc