Missing information is that the hysteresis is symmetrical around the reference level (two dotted lines above and below)
Count a point if,
- fall down crossing upper threshold and reference
- rises up crossing lower threshold and reference
- switch between fall down or rise up logic only if the signal crossed the threshold

The middle peak points is not counted because the signal did not cross the lower threshold after the first sample.