Average Price
I. What is Average Price
Average Price is a simple price calculation method that takes the arithmetic mean of the four price elements of a single bar — Open, High, Low, and Close. It provides a comprehensive price representative of the trading activity within each bar.
Historical Background
Average Price was not “invented” by a particular analyst; rather, it is a price representation method rooted in basic statistical thinking. During the early development of technical analysis, analysts needed a more comprehensive way to describe the price level of each bar than simply using the close price. Taking the average of all four OHLC prices was the most natural choice. This practice has a long history in both Japanese candlestick analysis and Western bar chart analysis.
Unlike Typical Price (three-price average) and Median Price (two-price average), Average Price incorporates all four price components, providing the most comprehensive single-bar price summary.
Indicator Classification
- Type: Overlay indicator, plotted directly on the price chart
- Category: Other Overlay / Price Transform
- Default Parameters: No parameters; calculated independently for each bar
- Data Requirements: Requires OHLC data
Most indicators default to using the close price as input. However, the close price only reflects the last traded price, whereas Average Price accounts for the opening contest, intraday volatility (high and low points), and the final settlement (close), providing a more balanced price perspective.
II. Mathematical Principles and Calculation
Core Formula
The Average Price calculation is extremely simple — the arithmetic mean of the four OHLC prices:
Where:
- is the open price of bar
- is the high price of bar
- is the low price of bar
- is the close price of bar
Step-by-Step Calculation
- Obtain single bar data: Read the Open, High, Low, and Close prices for the bar.
- Sum: Add the four prices together.
- Divide by 4: Obtain the average price.
- Calculate per bar: Each bar is computed independently with no dependency on prior data.
Mathematical Properties
Average Price has the following mathematical properties:
- Boundedness: — the average price always falls between the high and low
- Equal weighting: Each of the four prices has a weight of
- Memoryless: Each bar’s AP is computed independently without relying on historical data
Relationship with Other Price Types
Several commonly used price calculations can be understood within a unified framework:
| Price Type | Formula | Prices Included |
|---|---|---|
| Average Price | O, H, L, C | |
| Typical Price | H, L, C | |
| Median Price | H, L | |
| Weighted Close | H, L, C (C double-weighted) |
Different price types correspond to different “information emphasis.” Average Price is the most balanced; Typical Price gives more weight to the closing price; Median Price focuses only on the center of the volatility range. The choice depends on the analytical objective.
III. Python Implementation
import numpy as np
import pandas as pd
def average_price(open_: pd.Series, high: pd.Series,
low: pd.Series, close: pd.Series) -> pd.Series:
"""
Calculate Average Price
Parameters
----------
open_ : pd.Series
Open price series
high : pd.Series
High price series
low : pd.Series
Low price series
close : pd.Series
Close price series
Returns
-------
pd.Series
Average price series
"""
result = (open_ + high + low + close) / 4.0
result.name = "AvgPrice"
return result
def average_price_numpy(open_: np.ndarray, high: np.ndarray,
low: np.ndarray, close: np.ndarray) -> np.ndarray:
"""
Calculate Average Price using numpy (for understanding the principle)
"""
return (open_ + high + low + close) / 4.0
# ========== Usage Example ==========
if __name__ == "__main__":
np.random.seed(42)
dates = pd.date_range("2024-01-01", periods=100, freq="D")
price = 100 + np.cumsum(np.random.randn(100) * 0.5)
df = pd.DataFrame({
"date": dates,
"open": price + np.random.randn(100) * 0.3,
"high": price + np.abs(np.random.randn(100) * 0.6),
"low": price - np.abs(np.random.randn(100) * 0.6),
"close": price + np.random.randn(100) * 0.1,
"volume": np.random.randint(1000, 10000, size=100),
})
df.set_index("date", inplace=True)
# Calculate Average Price
df["avg_price"] = average_price(df["open"], df["high"],
df["low"], df["close"])
# Also calculate other price types for comparison
df["typical_price"] = (df["high"] + df["low"] + df["close"]) / 3
df["median_price"] = (df["high"] + df["low"]) / 2
# Print comparison results
print("=== Price Type Comparison (Last 10 Days) ===")
print(df[["close", "avg_price", "typical_price", "median_price"]].tail(10))
# Deviation analysis: Average Price vs Close
df["ap_close_diff"] = df["avg_price"] - df["close"]
print(f"\nMean deviation of Average Price from Close: {df['ap_close_diff'].mean():.4f}")
print(f"Standard deviation: {df['ap_close_diff'].std():.4f}")
# Use Average Price as input source for moving averages
df["AP_SMA_20"] = df["avg_price"].rolling(window=20).mean()
df["Close_SMA_20"] = df["close"].rolling(window=20).mean()
print("\n=== SMA(20) Based on Different Price Sources ===")
print(df[["AP_SMA_20", "Close_SMA_20"]].tail(10))
IV. Problems the Indicator Solves
1. Provides a More Comprehensive Price Representative
Using only the close price ignores intraday trading information. Average Price integrates four dimensions:
- Open price: Reflects overnight sentiment and the opening contest
- High price: Reflects the extreme reach of bullish forces
- Low price: Reflects the extreme reach of bearish forces
- Close price: Reflects the final consensus for the period
2. Serves as Input Source for Other Indicators
Many technical indicators allow selection of different price sources. Using Average Price as input can make these indicators smoother:
- Moving averages such as SMA and EMA
- Oscillators such as RSI and CCI
- Channel indicators such as Bollinger Bands
3. Smooths the Impact of Extreme Bars
In bars with long shadows (long upper or lower wicks), the close price may deviate significantly from the center. Average Price incorporates the high and low points, better reflecting the “center of gravity” of that bar’s trading activity.
4. Transaction Price Estimation in Backtesting
In quantitative strategy backtesting, if the model assumes execution within a bar, Average Price can serve as a reasonable transaction price estimate — it is closer to the true average execution cost than using Open or Close alone.
Average Price is calculated independently for each bar and does not produce trend or crossover signals on its own. It must be combined with other analytical methods to generate trading decisions.
V. Advantages, Disadvantages, and Use Cases
Advantages
| Advantage | Description |
|---|---|
| Extremely simple | Requires only one addition and one division, with no parameters |
| Comprehensive information | Incorporates all four OHLC prices, more complete than close alone |
| No lag | Calculated per bar with no window-induced lag |
| Highly versatile | Applicable to any timeframe and any market |
Disadvantages
| Disadvantage | Description |
|---|---|
| Limited signals | Does not generate buy/sell signals on its own; must serve as an auxiliary tool |
| Equal weight assumption | Assigns equal weight to all four prices, though the close may be more important |
| Ignores volume | Does not account for volume information and cannot reflect true transaction costs |
| Small difference from close | In clear trends, the difference from close is minimal, providing limited additional information |
Use Cases
- As an indicator input source: Replace close price as the calculation input for SMA, EMA, RSI, and other indicators
- Backtesting execution price estimation: A more reasonable assumed execution price in strategy backtesting
- Data smoothing preprocessing: A smoothed version of raw prices for quantitative modeling
- Multi-timeframe analysis: Better represents trading activity over a period than close price on larger timeframes
Comparison with Other Price Types
| Comparison | Average Price | Typical Price | Median Price | Close |
|---|---|---|---|---|
| Price factors | 4 (OHLC) | 3 (HLC) | 2 (HL) | 1 (C) |
| Close weight | 25% | 33% | 0% | 100% |
| Information completeness | Highest | High | Medium | Low |
| Common usage | General substitute | CCI/MFI input | Channel midline | Default input |
- If your strategy is sensitive to long shadows (e.g., using close price to trigger stop-losses), consider substituting Average Price for close to reduce the probability of being deceived by shadow “false breakouts.”
- When comparing intraday volatility across different assets, Average Price provides a more stable baseline than close price.
- For Heikin-Ashi candlestick analysts, Average Price is actually the definition formula for the Heikin-Ashi Close.