You may want to look at this topic from a few years ago where there is discussion and code samples for calculating Moving Average and Exponential Smoothing: Moving average
You may want to look at this topic from a few years ago where there is discussion and code samples for calculating Moving Average and Exponential Smoothing: Moving average