The MACD calculates the difference between two moving averages (typically, the 12- and 26-period), and then finds a moving average of that difference (typically, a 9-period moving average).
The MACD is calculated by simply subtracting a 26-period exponential moving average (EMA) of the closing prices from a 12-period EMA. The signal line is a nine-period exponential moving average of the MACD.