NinjaScript > Language Reference > Indicator Methods >

Moving Average - Variable (VMA)

Print this Topic Previous pageReturn to chapter overviewNext page


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.




VMA(int period, int volatilityPeriod)
VMA(IDataSeries input, int period, int volatilityPeriod)


Returns default value
VMA(int period, int volatilityPeriod)[int barsAgo]
VMA(IDataSeries 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.





Indicator source data (?)


Number of bars used in the calculation


The number of bars used to calculate the CMO based volatility index




// OnBarUpdate method of a strategy
protected override void OnBarUpdate()
   // Print out the VMA value of lows 3 bars ago for fun
  double value = VMA(Low, 9, 9)[3];
   Print("The value is " + value.ToString());


   // Go long if price closes above the current VMA value
  if (Close[0] > VMA(9, 9)[0])



Source Code

You can view this indicator method source code by selecting the menu Tools > Edit NinjaScript > Indicator within the NinjaTrader Control Center window.