The number of decimal places to round the VWAP value to
The multiplier for standard deviation bands (default: 2)
Maximum number of candles to keep in the session (default: 1000)
A new VWAP calculation session
import * as ta from 'chart-patterns';
// Create a new VWAP session with 2 decimal places precision, 2 standard deviations, and max 1000 candles
const vwapSession = ta.VWAP.createSession(2, 2, 1000);
// Process candles
for (const candle of candles) {
vwapSession.processCandle(candle);
}
// Get just the raw VWAP value without bands
const vwapValue = vwapSession.getRawVWAP();
// Get the current VWAP value with standard deviation bands
const { vwap, upperBand, lowerBand } = vwapSession.getVWAP();
// Reset the session (e.g., at the start of a new trading day)
vwapSession.reset();
// Reset and free memory in memory-sensitive environments
vwapSession.resetAndShrink();
Generated using TypeDoc
Creates a new VWAP calculation session.
The Volume-Weighted Average Price (VWAP) is a trading benchmark that shows the ratio of the value traded to total volume traded over a specific time period. It's calculated by adding up the dollars traded for every transaction (price multiplied by the number of shares traded) and then dividing by the total shares traded.