I recently read a paper where it was stated that calculus was used to calculate the slope of a moving average line at a given point. Given that there is no real formula to differentiate with a moving average calculation, what approach could the authors possibly be using?

  • $\begingroup$ what is "the moving average line"? $\endgroup$
    – leonbloy
    Jul 15, 2011 at 17:53
  • 1
    $\begingroup$ Do you recall the name of the paper you read? $\endgroup$
    – Jan Gorzny
    Jul 15, 2011 at 17:57
  • $\begingroup$ @leonbloy: Presumably the graph of the moving average, thought of as a smoothed curve through the actual discrete set of points. $\endgroup$ Jul 15, 2011 at 18:21
  • 2
    $\begingroup$ Is it possible that they simply meant that the slope was calculated as a difference quotient? In financial contexts I’ve seen both $\frac{x_n - x_{n-1}}{t_n - t_{n-1}}$ and $\frac{x_{n+1} - x_{n-1}}{t_{n+1} - t_{n-1}}$ referred to as the slope at $(t_n,x_n)$, where $x_n$ is the $n$-th moving average. Since the data are usually updated at constant intervals, the denominators usually normalize to $1$ and $2$, respectively. $\endgroup$ Jul 15, 2011 at 18:28
  • 1
    $\begingroup$ The paper in question is available at www.theastuteinvestor.net/f/IJEF_Published_Paper.pdf The relevant section is section 3 where it is stated "Using calculus, the nine and two-month SMA trend lines are converted into a mathematical model," followed by descriptions of use in sections 3.1 and 3.2 $\endgroup$ Jul 17, 2011 at 17:27

1 Answer 1


A moving average is, by definition, the average of some number of previous data points. In the case of continuous function $f:\mathbb{R}\to\mathbb{R}$, we can define the "simple moving average" (SMA) with window size $\mathbb{R}\ni w > 0$ to be the function

$$\bar{f}_w(x) = \frac{1}{w}\int_{x-w}^x f(y) dy $$

In the case of a discrete function $g: \mathbb{Z}\to\mathbb{R}$ as likely in the case of financial applications, the SMA with window size $w\in\mathbb{N}$ is simply

$$ \bar{g}_w(x) = \frac{1}{w}\sum_{k = 0}^{w-1} g(x - k) $$

Now, for the continuous case, by the fundamental theorem of calculus, the derivative of the SMA is simply

$$ \frac{d}{dx}\bar{f}_w(x) = \frac{1}{w}(f(x) - f(x-w)) $$

and for the discrete case, using the difference quotient, we have that

$$ D_- \bar{g}_w(x) = \frac{1}{w} (g(x) - g(x-w)) $$

Notice that the formula for the derivative of the SMA is the same in the discrete and continuous case!

Now, I cannot explain the sentence "Using calculus ..." The paper you linked to is also somewhat lacking in details for me to decipher what exactly the authors had in mind. One possibility, however, is that they just meant the above observation: even though the financial data is given discretely, and not continuously in time, we have that by the above observation the following nice fact:

Let $g:\mathbb{Z}\to\mathbb{R}$ be a function defined only on integer time-steps. And let $f:\mathbb{R}\to\mathbb{R}$ be any fixed arbitrary continuous extension of $g$; that is, $f$ is a continuous function with the property that $f(n) = g(n)$ for any integer $n$. Define the SMA as above and compute their derivatives, then necessarily $\frac{d}{dt}\bar{f}_w(n) = D_-\bar{g}_w(n)$ for any integer $n$.

Which says that "it doesn't matter that calculus cannot be applied to functions defined on a discrete domain; when dealing with SMAs, the discrete and continuous pictures give the same answers when you evaluate them at the integral timesteps."


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .