The following is the formula for calculating the MACD (Moving Average Convergence Divergence):
EMA1 and EMA2 are exponential moving averages at period t with different smoothing factors.
Reference: Appel, Gerard, The Moving Average Convergence Divergence Trading Method