RollingVWAP — Rolling VWAP
תוכן זה אינו זמין עדיין בשפה שלך.
The volume-weighted average of typical price over the last N bars. This is not session VWAP: it has no anchor and never resets at the open — session-anchored VWAP needs session-reset state the language does not have. The difference is large intraday; do not assume otherwise.
Signature
RollingVWAP(period, on=<source>)| Argument | Type | Required | Notes |
|---|---|---|---|
period |
int Param or literal | Yes | Sliding window. Default 20, bounds 1–400. |
on= |
symbol | No | Source symbol. Defaults to the trade symbol. Reads high, low, close, volume. |
Formula
$$ \text{RollingVWAP} = \frac{\sum_n TP_i \cdot V_i}{\sum_n V_i}, \quad TP = \tfrac{H+L+C}{3} $$
Warmup
period bars to a full window (partial before). A zero-volume window returns the current
typical price.
Reading the value
rv.valueself.trade.close < rv.valueExample
class VwapFade(Strategy): """Fade a stretch below the rolling VWAP.""" trade = Symbol() sizing = FixedCapital()
def execute(self): rv = RollingVWAP(20, on=self.trade) if self.trade.close < rv.value * 0.98 and self.trade.is_flat: self.buy(self.trade, reason="2% under rolling VWAP") if self.trade.close > rv.value and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="Back at VWAP")Notes
- The expressible cousin of session VWAP; weights typical price (not the close — that is
VWMA).