How to detect the edges of periodic signal? I have a periodic signal generated by accelerometer sensor and I need to count the number of peaks. However, I can't predict when the periodic sequence starts and ends. What would be the best way to do this if expected frequency of the useful signal is between 0.2Hz - 5Hz? 

Here is the example of the signal - five squats.
The autocorrelation function of a sliding window of data may change by a significant amount when the window is slid past the first or last cycle of your burst of periodic events.  You may have to play with the width of the autocorrelation window depending on the estimated frequency of your cyclic/periodic events.