Click or drag to resize

Volume Weighted Average Price

Vwap is the ratio of the value traded to total volume traded over a particular time horizon (minute or one day, etc).  It is a measure of the average price of a security traded over the designated trading range.  Vwap is often used as a trading benchmark by investors who aim to be as passive as possible in their execution.  Many pension funds, and some mutual funds, fall into this category.  The aim of using a Vwap trading target is to ensure that the trader executing the order does so in-line with volume on the market.  It is sometimes argued that such execution reduces transaction costs by minimizing market impact (the adverse effect of a trader's activities on the price of a security).

Calculation

Volume Weighted Average Price 001

Chart Example

Volume Weighted Average Price 002

Implementation and Usage

To initialize Vwap use one of the constructors provided:

Vwap – in this case indicator will be calculated by expanding window similar to cumulative moving average

Vwap(Int32) – sets period for indicator

Vwap(TimeSpan) – sets time period for indicator

Use

VWAP - property to get current value

Example
C#
 1// Create new instance
 2Vwap vwap = new Vwap(20);
 3
 4// Number of stored values
 5vwap.HistoryCapacity = 2;
 6
 7// Add new data point
 8vwap.Add(CurrentPrice, Bars.Current.Volume);
 9
10// Get indicator value
11double IndicatorValue = vwap.VWAP;
12// Get previous value
13if (vwap.HistoryCount == 2)
14{
15    double IndicatorPrevValue = vwap[1];
16}