Average
systemic:core-avgStatisticsInputs
| Name | Type | Description |
|---|---|---|
| Data | Number series | The series of numbers to compute the cumulative (running) average of. |
Outputs
| Name | Type | Description |
|---|---|---|
| Average | Number series | The running (cumulative) average: each bar holds the mean of all input values from the start up to that bar. |
Cost
0.202 + 0.00569·n credits for n bars, rounded up. The marks are each plan's limit of bars.
The Cumulative Average module computes the running mean of a series. At each bar, it returns the average of all values from the start up to that bar.
How It Works
flowchart TD
subgraph Input["Input Series"]
D["x1, x2, x3, ... xn"]
end
subgraph Process["Cumulative Calculation"]
S1["Position 1: x1"]
S2["Position 2: sum / 2"]
S3["Position 3: sum / 3"]
SN["Position n: sum / n"]
end
subgraph Output["Running Average"]
R["avg1, avg2, avg3, ... avgn"]
end
D --> S1 --> S2 --> S3 --> SN --> R
Step-by-Step Example
| Position | Input Value | Cumulative Sum | Running Average |
|---|---|---|---|
| 1 | 10 | 10 | 10.0 |
| 2 | 20 | 30 | 15.0 |
| 3 | 15 | 45 | 15.0 |
| 4 | 25 | 70 | 17.5 |
| 5 | 30 | 100 | 20.0 |
The Stabilization Effect
As more data accumulates, each new value has less impact on the average.
| After N Values | New Value Weight | Effect |
|---|---|---|
| 2 | 50% | High sensitivity |
| 10 | 10% | Moderate sensitivity |
| 100 | 1% | Low sensitivity |
| 1000 | 0.1% | Nearly stable |
Cumulative Average vs Moving Averages
| Aspect | AVG | SMA | EMA |
|---|---|---|---|
| Window | All data | Fixed rolling | Weighted decay |
| Memory | Full history | Limited | Fading |
| Sensitivity | Decreases | Constant | Constant |
| Best for | Baselines | Trends | Responsive |
The Philosophy of Averages
The arithmetic mean turns a set of observations into one representative value.
"The arithmetic mean is a point of balance—the fulcrum where all deviations cancel out."
The cumulative average has one special property: it remembers everything. A rolling window forgets old data; the cumulative average keeps the whole history. This is both a strength and a limitation:
- Strength: Provides a stable, long-term reference point
- Limitation: Slow to react to regime changes
Creative Application 1: The "Gravitational Pull" Trading Concept
Markets often seem to have a center of gravity. The cumulative average can serve as this "gravitational mean": a price level that prices tend to return to.
flowchart TD
subgraph MarketPhysics["Market Gravity Concept"]
PRICE["Current Price"]
AVG["Cumulative Average<br/>(Gravitational Center)"]
ABOVE["Price > Average<br/>Extension above equilibrium"]
BELOW["Price < Average<br/>Compression below equilibrium"]
end
PRICE --> |"Distance from center"| AVG
AVG --> ABOVE
AVG --> BELOW
ABOVE --> |"Pull back toward mean"| AVG
BELOW --> |"Pull back toward mean"| AVG
style AVG fill:#3498db,stroke:#fff,color:#fff
Research Insight: Studies on mean reversion suggest that extreme deviations from long-term averages tend to correct over time. The cumulative average is a neutral baseline because it weights every historical price equally. This idea underpins strategies like pairs trading and statistical arbitrage.
Creative Application 2: Dollar-Cost Averaging Tracker
Dollar-cost averaging (DCA) means buying at regular intervals. If you buy the same number of units each time, the cumulative average of the prices is your average cost. Comparing it with the current price shows whether you are buying at a premium or a discount.
flowchart LR
subgraph DCA["DCA Performance System"]
BUY["Monthly Purchase"]
PRICE["Current Price"]
AVG["Cumulative Avg<br/>(Your Cost Basis)"]
COMPARE{"Price vs Avg?"}
PREMIUM["Buying at Premium ⚠️"]
DISCOUNT["Buying at Discount ✓"]
end
BUY --> PRICE
BUY --> AVG
AVG --> COMPARE
PRICE --> COMPARE
COMPARE -->|"Price > Avg"| PREMIUM
COMPARE -->|"Price < Avg"| DISCOUNT
| Month | Price | Your Avg Cost | Status |
|---|---|---|---|
| Jan | $50 | $50.00 | — |
| Feb | $45 | $47.50 | Buying at discount |
| Mar | $60 | $51.67 | Buying at premium |
| Apr | $40 | $48.75 | Buying at discount |
| May | $55 | $50.00 | Buying at premium |
Key Insight: When the current price is below your cumulative average, your next purchase lowers your average cost. This view helps investors stay disciplined during drawdowns, when emotional selling is most tempting.
Practical Applications
1. Lifetime Performance Baseline
Track the lifetime average return of a strategy or portfolio. The stabilization effect makes this baseline steadier over time.
2. Fair Value Reference
Use the cumulative average of earnings, revenues, or other fundamentals as a "fair value" anchor.
3. Regime Detection
Compare current values to the cumulative average. Persistent deviations may signal regime changes:
- Sustained above average: Expansion regime
- Sustained below average: Contraction regime
Missing Data
Gaps in the input (a closed market, a missing value) are gaps in the output, never zero. The output is empty at that bar. The running average skips the gap and continues from the next value, so it only counts bars that have data.
Edge Cases
| Scenario | Behavior |
|---|---|
| Empty input | Returns empty output |
| Single value | Returns that value |
| Missing value (gap) | Output at that bar is empty; the running average continues from the next value, unaffected by the gap |
| All values missing | Every output value is empty |