Understanding the Mean
The arithmetic mean calculates a dataset's average. Sum all values. Divide by the count of values. It shows a central tendency. For example, five daily returns for AAPL: 1.0%, 0.5%, 1.2%, -0.8%, 1.1%. The mean return is (1.0 + 0.5 + 1.2 - 0.8 + 1.1) / 5 = 0.6%.
The mean is mathematically useful. It underpins many statistical models. Standard deviation and variance depend on the mean. In finance, the mean often represents an expected value. Traders use it for price targets or risk assessments. A stock trading above its 200-day moving average (a mean) suggests bullish momentum.
However, the mean is sensitive to extreme values. Imagine the AAPL returns again: 1.0%, 0.5%, 1.2%, -0.8%, 15.0%. The new mean is (1.0 + 0.5 + 1.2 - 0.8 + 15.0) / 5 = 3.38%. One extreme value dramatically shifted the average. This sensitivity makes the mean less dependable in volatile data.
Introducing the Median
The median identifies the middle value in an ordered dataset. First, sort the data from lowest to highest. If the dataset has an odd number of values, the median is the single middle number. If the dataset has an even number of values, the median is the average of the two middle numbers.
Consider the original AAPL returns: 1.0%, 0.5%, 1.2%, -0.8%, 1.1%.
- Sort the data: -0.8%, 0.5%, 1.0%, 1.1%, 1.2%.
- The median is 1.0%.
Now, consider the AAPL returns with the extreme value: 1.0%, 0.5%, 1.2%, -0.8%, 15.0%.
- Sort the data: -0.8%, 0.5%, 1.0%, 1.2%, 15.0%.
- The median is still 1.0%.
The median remained unchanged despite the extreme value. This shows its resilience. The median does not depend on the magnitude of extreme values, only their position.
When Stability Outweighs Precision
Mean reversion strategies often rely on price deviations from a central tendency. If the central tendency is unstable, the strategy generates false signals. This instability comes from extreme values. Extreme values in financial data include flash crashes, earnings surprises, or geopolitical events.
Consider a mean reversion strategy on a stock like TSLA. TSLA shows high volatility. Its daily returns frequently include large moves. A 20-day simple moving average (SMA) uses the mean. A single 10% daily move can significantly alter the SMA's path. This shift might trigger early trades or hide the true underlying central tendency.
For example, on January 26, 2021, TSLA dropped 8.6%. Its 20-day SMA for the period ending January 25 was $830. After the drop, the SMA for January 26 might shift significantly lower. This suggests an exaggerated mean reversion opportunity. A median-based average, like a 20-day moving median, would be less affected.
A 20-day moving median for TSLA would sort the last 20 daily closing prices. It would then select the 10th or 11th value. A large single-day price drop, like the 8.6% on January 26, 2021, would only shift one position in the sorted list. It would not drastically alter the median value. This makes the median a more stable reference point for mean reversion in assets prone to extreme values.
Institutional traders might use the median for identifying "fair value" in thinly traded assets. OTC stocks or illiquid bonds can have infrequent, large price movements. The mean would be highly distorted. The median provides a more reliable anchor.
Another application involves volume analysis. Large institutional orders can create volume spikes. A mean-based average daily volume (ADV) would be inflated by these spikes. A median ADV provides a better representation of typical trading activity. This helps identify genuinely unusual volume patterns, not just average distortions from extreme values.
For instance, consider a stock with average daily volume of 1 million shares. One day, a block trade of 10 million shares occurs. The mean ADV for the past 20 days would jump. The median ADV would likely remain near 1 million shares. This allows traders to distinguish between sustained volume interest and one-off events.
Implementing Median-Based Measures
Traders can implement median-based moving averages in their platforms. Many programming languages and statistical software packages offer median functions. Python's numpy.median or R's median() function calculate medians efficiently.
For a 20-period moving median of closing prices:
- At each new period, take the last 20 closing prices.
- Sort these 20 prices.
- Calculate the average of the 10th and 11th sorted prices. This is the moving median.
Compare a 20-day SMA to a 20-day moving median for a volatile asset like NVDA. On August 24, 2023, NVDA rose 3.17%. On August 25, it fell 2.44%. The SMA would react more sluggishly to these individual movements, but would also be more prone to larger shifts from extreme single-day moves. The median would hold its position, providing a more consistent central reference.
Consider a mean reversion strategy trading EUR/USD. Forex markets can experience rapid, large moves during news events. A 50-period moving median on a 1-hour chart will provide a more stable reversion level than a 50-period SMA during these events. If EUR/USD spikes 100 pips on an ECB announcement, the SMA will jump significantly. The median will only shift if the spike changes its ordinal position in the dataset.
Use the median when your data distribution is highly skewed or contains frequent extreme values. This often applies to short-term price data, volume data, or data from illiquid markets. The median provides a robust estimate of central tendency. This robustness is essential for stable mean reversion signals. It prevents false positives from average distortions caused by extreme values.
