# Autoregressive Exponential Moving Average Forecasting

I've recently been looking into an automated strategy to implement to my forex trading. School has been real busy and I haven't gotten much time to do technical analysis so I think it'd be better to explore robot trading. In this post I'll be discussing my strategy, it's properties and an example with a simple out-of-sample forecasting benchmarking against an ARMA(2,2) and Random-Walk naive prediction. In the next article, I'll write about implementing it in MetaTrader (MQL4).

An exponential moving average is an extension of a simple moving average where more of the weight is being placed upon the more recent observations. It can be defined as  where . By recursive substitution, it can be shown that the weighting will get exponentially smaller (hence the name) on older observations. Many technical analysts prefer EMA over SMA due to less lag on the charts.

Since we know that non-stationary time-series are harder to analyze due to time-varying conditional means and variances, we want to find a set of approximately stationary series to  forecast and trade.   Combining the idea that financial returns are mean reverting, We can obtain this weak stationarity by using the exponential moving average.  The model itself assumes that the best next-period forecast is the current period moving average.  Lastly, there is often time-dependence between the models innovations (), we can estimate this error with a standard AR model.  Thus, we arrive at our final model, let's call it AREMA(b,q):

For q=1:

where  is the averaging period (in our example it will be 3) and  are the auto-regressive error lags.  On Tradingview we can visualize this stationarity for Gold using a custom indicator that I created:

The goal of this article is to see if the AREMA forecasting can outperform other traditional benchmarks.  Taking Gold Spot Prices (XAUUSD) from 10/3/2013 to 10/8/2014, I take the last 65 of total 265 observation to be the test set.  The forecasting is done in a one-period ahead fashion without any parameter updates.  The first 200 observation are fed into models to be estimated and the remaining 65 are used for out-of-sample forecasting.  The performance criteria used will be Mean Squared Error.  Lastly, I will be benchmarking AREMA(3,1) with a traditional random-walk prediction (where the best forecast is the current period close), ARMA(2,0,2) and AREMA(3,0) such that we assume the errors are uncorrelated and hinder out-of-sample forecast performance.

In AREMA forecasting, we obtain a Mean squared error of 87.5813.  Below is a chart of the out-of-sample fit and actual, as you can see, the predictions are lagged by one period.  This is primarily due to the moving average being a lagging indicator itself.

In Random-walk naive forecasting, we obtain a Mean squared error of 87.8097, slightly worse than AREMA which makes our model look bad.

In ARMA(2,2) forecasting, we obtain a Mean squared error of  108.623, therefore we can say that the AREMA and naive model has outperformed the ARMA in Out of Sample forecasting of Gold Prices.  Below is the chart of the fit vs actual.

In conclusion, the AREMA model can outperform ARMA in some cases but only slightly improve on top of the naive forecasting method.  It isn't necessarily a better model especially when confronted with sudden large shocks but can help in some cases.  Modelers can look toward this method as a means of predicting non-stationary time series.  However, in our case, it is enough to be the basis for our trading system and we will look into implementing and backtesting the strategy in MetaTrader 4.  Thanks for reading.