Skip to content
Open RaamTrade

TypicalPrice — Typical Price

The one-number summary of a bar: the mean of high, low and close. CCI, MFI and rolling VWAP are all defined on it; having it as a named indicator lets a strategy read or smooth it directly.

Signature

TypicalPrice(period, on=<source>)
Argument Type Required Notes
period int Param or literal Yes Simple-average smoothing window. 1 (the default) returns the raw transform. Bounds 1–200.
on= symbol No Source symbol. Defaults to the trade symbol. Reads high, low and close.

Formula

$$ \text{TP}_t = \frac{H_t + L_t + C_t}{3} $$

With period > 1, the value is the simple average of the last period typical prices.

Warmup

period bars. During the lead-in the value is the average of the bars seen so far (with period=1 there is no lead-in).

Reading the value

tp.value
tp.value_at(1)
tp > sma.value

Example

class TypicalCross(Strategy):
"""Fade a close that stretches away from the smoothed typical price."""
smooth = Param(20, min=1, max=200)
trade = Symbol()
sizing = FixedCapital()
def execute(self):
tp = TypicalPrice(self.smooth, on=self.trade)
if self.trade.close < tp.value * 0.97 and self.trade.is_flat:
self.buy(self.trade, reason=f"3% under typical {tp.value:.2f}")
if self.trade.close > tp.value and self.trade.is_long:
self.sell(self.trade, self.trade.position, reason="Back at typical")

Variants

TypicalPrice(1) # the raw (H+L+C)/3 series
TypicalPrice(20) # a smoothed centreline

Notes

  • Standard price transform; the definition every platform agrees on.
  • Proven by an assert-via-trade run on SPY daily (raw value and 3-bar smoothing both matched a strategy-side reference on every bar; zero alarm trades).
  • MedianPrice drops the close; WeightedClose doubles it; AveragePrice adds the open.