Moving Average - Variable (VMA)

View as Markdown

Description

A Variable Moving Average is an exponential moving average that automatically adjusts its smoothing percentage based on market volatility. Giving more weight to the current data increases sensitivity thus making it a better signal indicator for short and long term markets.

Syntax

VMA(int period, int volatilityPeriod)

VMA(ISeries\<double\> input, int period, int volatilityPeriod)

Returns default value

VMA(int period, int volatilityPeriod)[int barsAgo]

VMA(ISeries\<double\> input, int period, int volatilityPeriod)[int barsAgo]

Return Value

double; Accessing this method via an index value [int barsAgo] returns the indicator value of the referenced bar.

Parameters

ParameterDescription
inputIndicator source data (Series<T>)
periodNumber of bars used in the calculation
volatilityPeriodThe number of bars used to calculate the CMO based volatility index

Examples

1// OnBarUpdate method of a strategy
2protected override void OnBarUpdate()
3{
4 // Print out the VMA value of lows 3 bars ago for fun
5 double value = VMA(Low, 9, 9)[3];
6 Print("The value is " + value.ToString());
7
8 // Go long if price closes above the current VMA value
9 if (Close[0] > VMA(9, 9)[0])
10 EnterLong();
11}

Source Code

You can view this indicator method source code by selecting the menu New > NinjaScript Editor > Indicators within the NinjaTrader Control Center window.