Summary

Returns the Simple Moving Average indicator instance.

Syntax

SimpleMovingAverage(DataSeries source, int periods)

Parameters

Example

 
//...
[Parameter]
public DataSeries Source { get; set; }

[Output("Result", Color = Colors.Orange)]
public IndicatorDataSeries Result { get; set; }
[Output("previousResult", Color = Colors.Green)]
public IndicatorDataSeries previousResult { get; set; }

private SimpleMovingAverage sma;

protected override void Initialize()
{
    sma = Indicators.SimpleMovingAverage(Source, 50);
}
public override void Calculate(int index)
{
    Result[index] = sma.Result[index]; //This stores current sma to Result Output
    previousResult[index] = sma.Result[index-1]; //This stores previous sma to previousResult Output
}
//...