title: How to Calculate All The Gradients of the Curves of a Graph
body: <p>I haven't seen an exact answer to this anywhere. I'm generating financial graph data. The data points could generate curves, lines, sharp points etc.</p>
  <p>I'm trying to develop an algorithm whereby I can determine up trends, sideways trends, and down trends from the gradients of the graph. For instance, if the gradient between three sets of sequential data points is of a similar value, we have a consistent trend.</p>
  <p>I can obviously calculate the grade/gradient as a percentage with (y2-y1)/(x2-x1) but the y-axis is just minutes/hrs/days, and the x values could be quite large or small so there needs to be some sort of normalisation to keep the gradients of the various graphs between, say, 0 to 100 and 0 to -100 (for a downward slope), where 0 would be a horizontal gradient.</p>
  <p>I feel like I would need to calculate and recalculate gradients based on similar previous gradients and would need to do a decent amount of calculations to determine one consistent similar uptrend for, say, 10 data points.</p>
  <p>Surely this problem has already been solved or there is some sort of quick approximation that can be made so I can at least determine data points that have a similar gradient?</p>
  <p>Oh, also, I'm doing all this in JavaScript but am using Decimal.js which seems pretty accurate, so I know my data points are valid.</p>
  <p>Thanks ahead of time!
  Ged</p>