The Harmonic Mean averages the reciprocals of the positive source values in the lookback window and then inverts the result. Put another way, it is the number of values divided by the sum of one over each value. Small values have large reciprocals, so they carry more weight, and the harmonic mean sits at or below both the geometric and the arithmetic mean of the same window.
The study keeps a running sum of reciprocals and a count of the values in the window. Each bar adds the new value and takes out the value that has just left the window. A value that is missing, zero or negative is skipped and does not count. The window grows from the first bar, so the first reading is on bar 0 and the full length bar window is in place once enough bars have passed.
It is drawn in its own pane so the line can be read on its own scale.
How to read Harmonic Mean (HARMEAN)
Treat it as a centre line that leans toward the low end of the window. When the harmonic mean falls clearly below a simple average of the same length, the window holds a wide spread of values with some low readings pulling it down. When the two are close, the window is tight.
It is an average, so it lags price and carries no signal by itself. Its early bars are computed from fewer values than the full window, and any bar whose source is zero or negative is left out of the mean.
Settings
- Source (must be positive values)
- The series that is averaged. Bars whose value is zero or negative are left out of the window.
- Lookback Period
- How many bars the window covers. A longer window gives a smoother, slower line.
Frequently asked questions
Why is it lower than a simple moving average?
Averaging reciprocals gives the small values more weight, so the result leans toward them. For positive numbers the harmonic mean is never above the arithmetic mean.
What does it skip?
Any bar whose source value is missing, zero or negative. That bar still occupies a slot in the window but adds nothing to the mean.
When is a harmonic mean the right average?
When the values are rates or ratios. Averaging the prices paid when the same amount of money is spent on each bar gives the harmonic mean, not the simple one.
