A Simple Moving Average (SMA) is the unweighted mean of the previous n data points. For example, a 10-day simple moving average of closing price is the mean of closing prices for the previous 10 days.
To calculate the SMA:
- Compute the arithmetic average of first R rows, as specified by the Window_Size argument, N.
- For each subsequent row, compute new value as:
new_smavg = old_smavg - (PM-n-PM) / N