MEDPRICE computes the midpoint of a bar's High and Low: $(H + L) \times 0.5$. This is the simplest possible estimate of a bar's "fair value," splitting the difference between the session's extremes while ignoring both the opening gap and closing settlement. The result represents the geometric center of the bar's vertical range. Because it excludes Open and Close, MEDPRICE responds purely to the supply/demand boundaries that the market tested, making it a useful input for range-based indicators like CCI or as a detrending reference. Stateless, zero-warmup, one addition and one multiply per bar.
## Historical Context
Median Price (also called "Mid Price" or "HL/2") is among the most elemental price transforms, used long before computers entered trading floors. The TA-Lib function `TA_MEDPRICE` standardized the computation, and most charting platforms expose it as a built-in price source. The name "Median Price" is a slight misnomer in the statistical sense: it is the midrange (arithmetic mean of extremes), not the median of a distribution. The name stuck through decades of usage.
The key distinction from Typical Price ($HLC/3$) is the exclusion of Close. This matters when the closing price diverges significantly from the bar's center, as happens with gap-up closes, stop runs, or end-of-session order flow. MEDPRICE treats the bar as a symmetric range and asks: where was the midpoint of price exploration?
In QuanTAlib, `TBar.HL2` provides the same value as a zero-cost computed property. The `Medprice` indicator class wraps this in the streaming `ITValuePublisher` interface with bar correction, NaN safety, and event chaining support.
## Architecture & Physics
### 1. Core Formula
$$\text{MedPrice}_t = (H_t + L_t) \times 0.5$$
No FMA benefit here: the pattern is $(a + b) \times c$, not $a \times b + c$.
### 2. State Management
Stateless per bar. State exists only for:
- **Last-valid substitution**: Non-finite High or Low values are replaced with the last known finite value for that component.
- **Bar correction**: `isNew=false` rolls back to previous state for same-timestamp rewrites.
### 3. Complexity
$O(1)$ per bar. One addition, one multiply. No memory allocation. Always hot after the first bar.