[Python] How to detect crossovers between two superimposed time series with different Y scales...

Discussão em 'Python' iniciado por Stack, Maio 24, 2025.

  1. Stack

    Stack Membro Participativo

    I’ve a Python script that generates and plots two time series on the same chart, similar to how TradingView allows overlaying different assets. Each series has its own Y-axis scale, but visually they are superimposed to appear aligned — this mimics the "compare" or "add symbol" feature in TradingView.

    The problem: While the plot looks visually correct, due to the underlying difference in scale, I'm unable to accurately detect crossover points between the two series in code given lot of stocks to compare. The series appear to cross visually, but numerically they don't intersect in a meaningful way due to scale differences.

    I’ve tried various suggestions from LLMs (ChatGPT, Claude, DeepSeek, etc.), including:

    Pattern recognition

    Normalization (min-max, z-score)

    Dynamic time warping

    Human-machine pattern recognition analogies

    Curve fitting

    Also they fail to pick up pixel by pixel even after using generated plot coordinates.

    None of these approaches successfully identify the actual crossover points when executed in Python. Most models (FREE) can recognize the cross visually on their server in their response but fail to translate that into usable Python code that works on my system.

    What I'm looking for: A reliable method in Python to detect the visual crossover points as they appear on a dual-scale plot — ideally without losing the scale integrity of each individual series.

    Other info:

    Using matplotlib for plotting

    Series may represent stocks or indicators with differing magnitudes

    Crossovers must reflect visual alignment on the plot, not strict numerical equality

    Any techniques or libraries that solve this kind of "visual" crossover detection would be greatly appreciated.

    Continue reading...

Compartilhe esta Página