Finding series intersection lazarus / 55-TAChart ---------------------------------------------------------------------- celso · 2022-12-26 15:12 In this chart attached, I have two series one is a TLineSeries (the blue one), and another is a TExpressionSeries (the red one). I need to know where the lines cross with each other, the intersection, there is two points where it cross. There is any TChart tool I can use to detect it? Or any other way? ---------------------------------------------------------------------- wp · 2022-12-26 17:04 No, there is no ChartTool to calculate the intersection of two series. You must calculate this yourself: Iterate over all points of the LineSeries (make sure that it is sorted in x) and calculated the values of the ExpressionSeries at the x values of the LineSeries pointsFind the segment of the LineSeries (between x=x1 and x2) for which the y value of the ExpressionSeries at x=x1 is greater (or smaller) than the y value of the LineSeries at x1, and for which the y value of the ExpressionSeries at x=x2 is smaller (or larger) then the y value of the LineSeries at x2 -- now you know that the intersection occurs between the points at x1 and x2.Since each segment of a line series is a linear function you can calculated every point on this segment as y = (x-x1)(x2-x1)*(y2-y1) + y1This is needed when you apply a numerical algorithm such as Newton-Raphson to refine the intersection point: https://en.wikipedia.org/wiki/Newton%27s_methodAn alternative method is bisection in which the interval is recursively subdivided into halves so that the intersection point is always in that sub-interval for which the function series at one end is above (or below) and at the other end is below (or above) the lineseries. In the attachment there is an example how this could be coded. (Note that this code finds only a single intersection per segment). ---------------------------------------------------------------------- celso · 2022-12-28 18:29 Hello friend, sorry for the late answer, thanks for your help, it worked just fine. For some reason the TChart inverted my values, but I could adjust it.