Little late on the reply, but here's how to do it. Instead of actually taking the derivatives of the SMA (since it would be tedious to find the actual function each candle), you can just test each data point for inflection. For instance, on a concave down, if you draw a line connecting two points on the curve, that line should never be greater than the concave down function. If you constantly test the current SMA value to, lets say 3 candles back, you can theoretically test for inflection. For instance, once SMA[-2]<(inflectionPoint[-3]+inflectionPoint)/2, you have found yourself an inflection point. If you need a better understanding, feel free to DM me (math is my thing).