What a moving average shows

A moving average is the mean of the last N prices. When a new price arrives, the oldest price drops out of the window and the average is calculated again.

A moving average is the ordinary mean of the most recent prices, updated every time a new price arrives. Add the prices in the window, divide by how many there are, and that quotient is the average. On the next bar, the oldest price leaves and the new price joins. The average is calculated again.

The mean of a window

The NIST engineering statistics handbook writes the single moving average as the sum of the current observation and the N minus 1 observations before it, divided by N. The handbook section then advances one period, drops the oldest observation, and repeats. Each value in the window has the same weight. That equal weight is what makes the average "simple." An exponential average uses different weights, with more weight on newer prices. This page is only the equal-weight version.

Until the window is full, there is no average of length N. Three prices are required before a length of 3 exists. The earlier bars stay blank rather than pretending a shorter window is the same calculation.

One window, then the next

These figures are a worked example, not a recorded run. The closes arrive as 10, then 20, then 30, then 40. The window length is 3.

The first full window is 10, 20, and 30. The sum is 60. Divided by 3, the average is 20.

The next close is 40. The oldest close, 10, drops out. The new window is 20, 30, and 40. The sum is 90. Divided by 3, the average is 30.

The length stayed at 3. The average rose from 20 to 30 because the price that left was 10 and the price that arrived was 40. A reader who keeps adding prices without dropping the oldest one is computing a growing mean, not a moving average.

What Tradee computes

Tradee's simple moving average is that rolling mean. The default length is 20, and the default source is the close. The length can be set from 2 to 500. The source can be the open, the high, the low, the close, or a blend of those prices. Whatever source you pick, the node still returns one number per bar: the mean of the last N values of that source.

The first bars, before the length is filled, do not produce a value. A strategy that reads the average during that stretch is reading a missing input, not a quiet market.

The number is an input. An indicator is not a strategy is the split to keep: the average can sit on a chart, or inside a component, and still never enter or exit. A component is where the repeated calculation is saved. The entry, the exit, and the stop belong on the strategy that uses the number.

This article is for education. It is not financial advice. Trading can lose money. Past results do not guarantee future results.