The current implementation of get_local_max_and_min_idx only saves a point when it passes the current moving average. When there is a slack period between 2 points in the same region (both lower or both upper), the latter point gets filtered out which causes incorrect representation of the movement.

For the example above, green is actual movement and orange is generated movement.
Whether a slack/pause shall be filtered or not shall be determined by a time threshold parameter. (e.g. first short pause at the top)
The current implementation of get_local_max_and_min_idx only saves a point when it passes the current moving average. When there is a slack period between 2 points in the same region (both lower or both upper), the latter point gets filtered out which causes incorrect representation of the movement.

For the example above, green is actual movement and orange is generated movement.
Whether a slack/pause shall be filtered or not shall be determined by a time threshold parameter. (e.g. first short pause at the top)