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.

  • $\begingroup$ 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 ? $\endgroup$
    – mark leeds
    Sep 28, 2021 at 18:58
  • $\begingroup$ 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". $\endgroup$
    – user42108
    Sep 28, 2021 at 20:52
  • $\begingroup$ 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, $\endgroup$ Sep 28, 2021 at 20:55
  • $\begingroup$ @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. $\endgroup$ Sep 28, 2021 at 20:56

1 Answer 1


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.

As you can see, this is one possible way to determine an "optimal" decay factor for an EWMA. I am sure that there is a lot of literature out there dealing with this type of problems and that there are for sure more sophisticated approaches. However, in my opinion the main problem is to find a good balance between simplicity and accuracy. Depending on your intended use, one may be weighted more than the other.

  • $\begingroup$ Thanks - this makes a lot of sense! In fact, I read that performing this sort of optimization is similar to fitting a random-walk with noise Kalman Filter. $\endgroup$ Sep 28, 2021 at 21:14
  • $\begingroup$ @rubikscube09: yes, if you use a KF and estimate a random walk + noise model, you can take your variance estimates and infer what the exponential smoothing parameter is. See Andrew Harvey's "Structural Time Series Models and the Kalman Filter" for the formula which I can't remember off the top of my head. $\endgroup$
    – mark leeds
    Sep 29, 2021 at 0:07
  • $\begingroup$ @markleeds - thank you! I'll take a look. The Kalman formulation, although it is ultimately an optimization routine, makes conceptual sense. $\endgroup$ Sep 29, 2021 at 1:01
  • $\begingroup$ rubikscube09: You're welcome. The equivalences are generally not explicitly stated in textbooks but ARIMA(0,1,1) equals random walk + noise which equals exponential smoothing which almost equals moving average. Of course, this is only true when relations between the various parameters hold. $\endgroup$
    – mark leeds
    Sep 29, 2021 at 15:10
  • 1
    $\begingroup$ rubikscube09: the one nice thing about the KF random walk + noise approach or the exponential smoothing compared to the moving average approach is that there is no arbitrirary choice of the value of the moving window. All the data is used and how much one weighs each observation ( which ultimately depends on the signal to noise ratio ) is the underlying issue. $\endgroup$
    – mark leeds
    Sep 30, 2021 at 3:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.