Keep it simple!
The moving average seems to be a pretty good damper device ; keep it as it is, perhaps only increasing or decreasing its number of samples if you notice that it either makes too much noise or deletes the signal too much. Then you turn off this averaged signal.
The pattern markers you are looking for are relatively easy to detect. Expressed in English, these markers:
Goals = inflection points in the curve of averaged readings when the slope becomes noticeably negative to positive.
Therefore, you should determine this situation by comparing the slope values calculated together with the moving average , since each new reading value is available (of course, with a slight delay, since, of course, the slope at a given point can only be calculated with an average reading for the next [several ] points [s])
To avoid false detection, you need to define several parameters aimed at filtering unwanted patterns . These parameters will more accurately determine the “noticeable” value in the above definition of target.
Roughly a formula for finding a point of interest can be as simple as this (- 1 * S (t-1) + S t )> Min_delta_Slope
Where
S is the slope (moreover) at time t-1 and t, respectively Min_delta_Slope is a parameter that defines how “sharp” change in the slope we want at least.
Assuming the normalized units are t and Y, we can set the Min_delta_Slope parameter close to or even minus 1. Intuitively, a value of 1 (again in normalized units) indicates that we aim at points where the profit curves are in a downward slope, for example, 50% and left a point with an upward slope of 50% (or 40% + 60% or .. 10% i.e. almost flat and 90%, i.e. almost vertical).
To avoid detecting points in the case when it is just a small dip in the curve, we can take into account more points, with the fancier formula, for example, say
(Pm2 * S (t-2) + Pm1 * S (t-1) + P0 * S t + Pp1 S (t + 1) )> Min_delta_Slope
Where
Pm2, Pm1, P0 and Pp1 are coefficients that give the relative importance of the slope at different points before and after the point of interest. (Pm2 and Pm1 are usually negative values, unless we use only the positive parameter and do not use negative signs in the formula)
S t +/- n is the slope at different times
and Min_delta_Slope is a parameter that defines how “sharp” change in the slope we want at least.
Intuitively, this four-point formula would take into account the shape of the curve for two-point readings before and two readings past the point of interest (in addition to looking at the point immediately before and after it). Given the correct values of the parameters, the formula will require that the curve steadily approaches down to two time slices, and then steadily rises to the next two time slices, therefore avoiding marking smaller dips on the curve. An alternative way to achieve this can be to calculate the slope using the difference in the Y value between the [average] reading from two (or more) time intervals backward and the current [average] reading. These two approaches are similar, but will bring a slightly different result; as a rule, we could say more about the desired curve shape with the parameters Pm2, Pm1, P0 and P1.