PriceVolumeTrend — Price Volume Trend
תוכן זה אינו זמין עדיין בשפה שלך.
OBV’s better-behaved cousin: instead of adding the whole bar’s volume on any up close, it adds volume scaled by how far price actually moved. A 0.1% up day contributes a hundredth of what a 10% day does.
Signature
PriceVolumeTrend(period, on=<source>)| Argument | Type | Required | Notes |
|---|---|---|---|
period |
int Param or literal | Yes | SMA smoothing of the line. 1 returns the raw accumulator. Bounds 1–200. |
on= |
symbol | No | Source symbol. Defaults to the trade symbol. Reads close and volume. |
Formula
$$ \text{PVT}t = \text{PVT}{t-1} + V_t,\frac{C_t - C_{t-1}}{C_{t-1}} $$
Warmup
Starts at 0 and accumulates; resets per run and per walk-forward window.
Reading the value
pvt.valuepvt.value > pvt.value_at(20)Example
class PvtConfirm(Strategy): """Hold only while the volume-weighted trend line is rising.""" trade = Symbol() sizing = FixedCapital()
def execute(self): pvt = PriceVolumeTrend(1, on=self.trade) if pvt.value > pvt.value_at(20) and self.trade.is_flat: self.buy(self.trade, reason="PVT rising") if pvt.value < pvt.value_at(20) and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="PVT falling")Notes
- The standard PVT accumulation.
- Unbounded and path-dependent like OBV: read the slope and divergences, never the level.
- Ours cumulates the fractional return × volume, so it reads 0.01× pandas_ta’s
pvt(), which cumulates the percent return × volume.