Syntax
public static VMA Series(DataSeries source, int period)
public VMA(DataSeries source, int period, string description)
Parameter Description
source |
DataSeries |
period |
Indicator calculation period |
Note!
VMA combines the specified
DataSeries with Volume from the current Bars context. Consequently, to calculate VMA for a secondary symbol, first call SetContext(), assign VMA.Series() to a DataSeries variable, and then RestoreContext().
Description
VMA returns the Volume-Weighted Moving Average for the specified Price Series and Period. VMA is similar to a
SMA, but each bar of data is weighted by the bar's volume.
VMA places more significance on bars with the largest volume and less for bars with lowest volume for the Period specified. The VMA value attempts to represent the average purchase price of the past number of periods, as it assumes that all prices were traded at selected time (usually the closing value). Using VMA, you can judge if you are buying at a low value or selling at a high value compared to the averaged price paid by all market participants.
Because important breakouts are often accompanied by a large increase in volume, VMA will track aggressive moves more closely than other types of moving averages. During consolidation periods, where volume is light, VMA will act like a normal
SMA.
Interpretation
- Use the same rules that we apply to SMA when interpreting VMA. Keep in mind, though, that VMA is generally more sensitive to price movement on high volume days.
- VMA's are used to determine trend direction. If the VMA is moving up, the trend is up, if moving down then the trend is down. A 200-bar VMA is common proxy for the long term trend. 60-bar VMA's are typically used to gauge the intermediate trend. Shorter-period VMA's can be used to determine short-term trends.
- VMA's are commonly used to smooth price data and technical indicators. Applying a VMA smooths out choppy data. The longer the period of the VMA, the smoother the result, but more lag is introduced between the VMA and the source series.
- VMA crossing price is often used to trigger trading signals. For example, when prices cross above the VMA go long, and when they cross below the VMA go short.
- Look for differences between the SMA and the VMA with the same number of periods. When the VMA is above the SMA then buyers are active and are accumulating stock, go long. When the VMA is below the SMA then seller are active, and stock is being sold, go short.
Calculation
VMA = ( V
1 * P
1 + V
2 * P
2 + ... + V
n * P
n ) / ( V
1 + V
2 + ... + V
n )
where,
P
1 = current price
P
2 = price one bar ago, etc.
V
1 = current volume
V
2 = volume one bar ago
n = number of periods/bars
Example
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
protected override void Execute()
{
// Compare a Volume Weighted Moving Average with a standard MA
PlotSeries( PricePane, SMA.Series( Close, 60 ), Color.Blue, LineStyle.Solid, 1 );
PlotSeries( PricePane, VMA.Series( Close, 60 ), Color.DarkGreen, LineStyle.Solid, 2 );
}
}
}