# Moving Average Window Size Determination

Is there a "correct" way of determining a moving average window/smoothing parameter (or at least a starting guess for a financial time-series?

I understand of course that in some sense, this could be considered a "hyperparameter" for let's say - a trading strategy - and that one could use some kind of cross-validation to optimize it, but frankly this has little interpretability and starts to veer into what I'd consider overfitting territory. Moreover, if one has a strong initial guess, they can tune it with the same methods in a Bayesian sense, by concentrating the prior at the given initial guess.

Is there a way to such a guess using physical or economic fundamentals/reasoning? Something I considered was computing the Fourier Transform of the time-series in question (or of its autocorrelation function?), and then take the mode of the magnitude, e.g. $$w_{\text{opt}} = \mathrm{argmax}_{\xi}|\hat{f}(\xi)|$$

but frankly I only understand Fourier Analysis from a mathematical perspective, and not its application to discretely sampled signals (e.g. time-series), so I am not sure if this is a sensible idea.

• I think you'd have to explain why you want a moving average in the first place ? Also, there is a equivalence between exponential smoothing and a moving average so you could the ES formulation because it atleast has a "parameter" to optimize over. But first question is what the MA is for ? Sep 28, 2021 at 18:58
• I have seen people use a moving average (for economic rather than financial time series) set to what they consider the average length of the business cycle. You might consider this "economic fundamentals". Sep 28, 2021 at 20:52
• Thanks @markleeds - you made me think a bit more about my question. Essentially I have some signal (a time series) that I'm using to make predictions. This signal is unfortunately noisy (e.g. oscillatory) and this noise could be considered as a measurement noise. Thus, I'd like to recover from this measurement noise a "smoother" (big air quotes) time series. The most obvious way to do such smoothing is a moving average. One can also consider a univariate Kalman filter, although this reduces to an exponential moving average anyway, Sep 28, 2021 at 20:55
• @user42108 - that makes sense, my time-series is essentially a high-frequency (say daily) coincident estimate of current GDP growth. On one hand I could set it to such a large quantity, although on the other hand, I'd like to preserve the ability for the series to respond to shocks/changes in things. Of course - these two demands are basically antithetical to each other, and of course it is another question as to which innovations are "noise" and which are true shocks to economic conditions. Sep 28, 2021 at 20:56

I don't think that there is one right way to approach this problem. However, I will give an example which I found quite interesting. The JP-Morgan risk-metrics approach was (or still is I don't know) quite popular in the industry. They use an EWMA $$\sigma_{t}^2=(1-\lambda)r_{t-1}^2+\lambda\sigma_{t-1}^2$$ to predict daily or monthly volatility. For daily returns they use $$\lambda=0.94$$ as "optimal" decay factor for every time series. As a reason for that they wrote in their 1996 technical document that it is too elaborately to calculate an optimal decay factor for every time series for different time periods.
What they did instead is that they modelled the log returns $$r_t$$ via $$r_t= \sigma_t \epsilon_t \quad , \epsilon_t \overset{iid}{\sim} {\cal N}(0,1)$$ where $$\sigma_t^2$$ is modelled via the EWMA above. Now for $$N$$ different time series, they defined the root mean squared error (RMSE) as: $$RMSE=\sqrt{\frac{1}{T}\sum_{t=1}^T(r_t^2-\sigma_t^2)^2}$$ Now let $$\hat{\lambda}_i$$ denote the optimal decay factor for time series $$i$$ (that one which minimises the RMSE) and $$\tau_i$$ the corresponding value of the RMSE. They calculated the sum of the minimum RMSE's $$\sum_{i=1}^N\tau_i$$ used this quantity to calculate an relative RMSE $$\theta_i= \frac{\tau_i}{\sum_{i=1}^N\tau_i}$$ then used this quantity to derive the weights $$\omega_i = \frac{\theta_i}{\sum_{i=1}^N\theta_i}$$ and finally got $$\lambda = \sum_{i=1}^N\omega_i\hat{\lambda}_i \approx 0.94$$ as optimal decay factor over $$N$$ time series.