def calculate_ema(close, periods, previous_ema):
    """
    Calculates the exponential moving average.
    EMA = Price(t)*weighting_multipler + previous_ema*(1-weighting_multiplier)
    *weighting_multiplier is given by 2/(periods + 1)

    Args:
        close: Float representing the exchange rate at the end of an interval
        periods: Integer representing the number of days in the EMA period (commonly 12 or 26)
        previous_ema: Float representing the last calculated EMA

    Returns:
        Float representing the new EMA
    """
    return close*(2/(periods + 1)) + previous_ema*(1-(2/(periods + 1)))