Harmonic MA
By LuxAlgoApr 9, 2026
Harmonic MA is the definitive standalone build of the harmonic MA: each bar it inverts the last 20 source values, averages the reciprocals and inverts the result, handing the smallest window values outsized influence. Dips drag the line down harder than spikes lift it, and for positive data it holds at or under the same-length SMA plotted beside it — nearly identical through quiet ranges, sagging visibly once a steep selloff lands inside the window. Slope coloring, a price gradient fill and a dashboard reporting the gap to the SMA complete the tool.
How to Trade the Harmonic MA?
- Rising line: the slope turned positive — the bullish color and the Harmonic MA Slope Up alert mark the smoother's trend read.
- Price above the line: the bullish side of a deliberately conservative baseline, since the harmonic mean refuses to chase upside outliers.
- Gap to SMA widening: the window now spans large swings — a stress gauge this pair of lines measures directly.
- Bearish price cross: after sharp dips this fires slightly earlier than against an arithmetic baseline, because the line leans toward the window's lows.
Among the trend smoothers this one changes the mean, not the schedule; the Vs SMA row quantifies the sag in percent.
Harmonic MA Settings
- Source (default close): must be strictly positive — prices, volumes or ratio-like series, never returns or oscillators that cross zero.
- Harmonic Length (default 20): window size N in H = N / sum of reciprocals.
- SMA — Same Length (default enabled): the arithmetic comparison line.
- Show Dashboard (default enabled): length, gap, slope and price position.
- Slope Trend Coloring (default enabled): color the line by slope, or draw it in the neutral color.
- Style toggles: gradient fill on, crossing markers off, line width 2.
Frequently Asked Questions
How does the Harmonic MA differ from a Sine-Weighted MA?
A Sine-Weighted MA changes which bars matter, emphasizing the middle of the window through a sine profile. The harmonic MA keeps equal weights but changes the mean itself — shifting the line's level toward the window's lows rather than reshaping its timing.
Is the harmonic mean faster than an SMA?
No. It turns when a same-length SMA turns; the mean type moves the level, not the lag.
What happens if the source touches zero or goes negative?
The reciprocal math becomes undefined, so any window holding a non-positive value plots nothing, the dashboard warns, and the Non-Positive Input alert fires. Feed it raw prices or other strictly positive series.
The Library is free. Quant makes it yours.
Pull any concept or indicator into Quant: rebuild it, retune it, or turn it into a backtested strategy of your own.
