Is there an algorithm for second order filtering of data where the filter frequency is not known a priori?
The formula $$ a_n = a_{n-1} \frac{n-1}{n} + \frac{x_n}{n} .$$
is a way to compute the average of $n$ samples, and update this average whenever a new sample is obtained, without storing all of the samples individually.

Ignoring the part about online computation, I think your question is equivalent to "is there a way to estimate the mean of N identically distributed random variables that has lower standard deviation than the arithmetic average?"  If so, the answer is: no, there isn't.

I would also worry about the numerical behavior of this formula for large $n$.