A simple moving average algorithm