Volume-weighted Moving Average (VWMA)
Last updated
Last updated
// Prints the current value of a 20 period VWMA using
// the daily bars close price value.
vwma = indicators.VWMA(20, BarValueType.Volume).OnSeries(dailyBars);
Log("The current VWMA value is " + vwma.Value.ToString());
// Prints the previous value of VWMA.
vwma = indicators.VWMA(20, BarValueType.Volume).Keep(2).OnSeries(dailyBars);
Log("The previous VWMA value is " + vwma.Values[1].ToString());using Signals.DataSeries.Bars;
using Signals.Framework;
using Signals.Indicators.VWMA;
public class MyStrategy : SingleMarketStrategy
{
private Bars dailyBars;
private VWMA vwma;
public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
{
dailyBars = data.Bars(BarPeriodType.Day, 1).WithOffset(25);
vwma = indicators.VWMA(20, BarValueType.Volume).Keep(2).OnSeries(dailyBars);
}
public override void RegisterActions()
{
OnUpdateOf(dailyBars).Do(() =>
{
// Prints the current VWMA value
Log("The current VWMA value is " + vwma.Value.ToString());
// Prints the previour VWMA value
Log("The previous VWMA value is " + vwma.Values[1].ToString());
});
}
}