Visual Basic (Declaration)  

Public Overloads Shared Function SimpleMovingAverage( _ ByVal seriesName As String, _ ByVal s As Series, _ ByVal elementValue As ElementValue, _ ByVal lengthOfMA As Integer _ ) As Series 
Visual Basic (Usage)  Copy Code 


C#  

public static Series SimpleMovingAverage( string seriesName, Series s, ElementValue elementValue, int lengthOfMA ) 
Parameters
 seriesName
 The name of the series which will be displayed on the chart, i.e. its label.
 s
 A series where the first term is the most recent historical price, the second term is the previous historical price and so on.
 elementValue
 Specifies the particular element value (for example High, Low, Close or Open of the financial time series) which will be considered within this indicator evaluation. In particular, if you wish to use the element value high then you should pass the parameter High. In a similarly fashion if you wish to use the low, close or open, then you should pass the parameter Low, Close, Open, respectively.
 lengthOfMA
 The number of periods considered within the evaluation of the moving average for each of the periods on which it can be evaluated.
Return Value
A series where the first term corresponds to the Moving Average on the last period and the previous value is the value of the Moving average on the previous period and so on.Exception  Description 

ArgumentException  Thrown if the series is empty. 
Illustration
If we are considering a traded asset and the periods considered are days then by
passing an array containing the closing daily prices of a given asset, and by choosing
to use the 5day moving average (i.e. passing a length of the MA of 5
),
then this method will evaluate the Moving Average (MA) for all days for which the closing
price on that day and the four previous days is known.