Incremental Moving Averages Without Intermediate Indicator Buffers
Summary
This article presents a way to compute moving averages and other intermediate series without storing a full history in extra indicator buffers. A stateful function receives one bar’s input at a time, updates an internal rolling selection, adds the newest observation, and removes values that have aged beyond the averaging window. Because the calculation is incremental, the article says it can avoid a second pass over a buffer and reduce repeated work.
The implementation groups the state in class instances so separate averaging operations do not share working memory, and keeps those instances static across calculation calls. It demonstrates chaining simple, exponential, smoothed, and weighted averages, with each result feeding the next. The method depends on processing earlier bars before the current bar and on careful initialization for history limits and repeated updates to an unfinished bar. It is a programming technique for indicator efficiency, not a trading strategy; the excerpt gives design rationale and examples but no benchmark figures for the proposed implementation.
Key ideas
- A one-bar-at-a-time averaging function can maintain only the values needed for its current window.
- Incremental updates add the latest observation and remove the oldest rather than recomputing the whole average.
- Separate class instances keep the state for multiple averaging operations independent.
- Static instances preserve internal state across indicator calculation calls.
- Correct results depend on initialization, bar order, and handling updates to the current unfinished bar.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.