To calculate a simple moving average, simply add up closing prices of a security over a certain time frame and then divide by the number of periods (i.e. trading days) observed. For instance, consider shares of XYZ stock closed at $100, $110, $120, $110, $140 over a five-day period, the 5-day SMA would be 116.