Caleb Ziegler's moving average code