• Detects bullish and bearish divergences between price action and a custom technical indicator.

    This generic function allows you to detect divergences with any custom indicator values. The indicator values array must have the same length as the candles array and represent the indicator value for each corresponding candle.

    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
    • indicatorValues: number[]

      Array of custom indicator values (same length as candles)

    Returns IDivergence[]

    Array of detected divergences with timing, strength, and description

    Example

    // Example with custom MACD values
    const macdValues = calculateMACD(candles); // Your custom indicator calculation
    const zScoreConfig = { lag: 3, threshold: 1, influence: 0.75 };

    const customDivergences = Divergences.custom(candles, zScoreConfig, macdValues);

    customDivergences.forEach(div => {
    console.log(`Custom indicator divergence found: ${div.description}`);
    console.log(`Points involved: ${div.points.length}`);
    });

Generated using TypeDoc