Skip to content

IIndicatorsAccessor.MovingAverage

method · IIndicatorsAccessor · cAlgo.API.Internals

DesktopCLICloud

Moving Average indicators are used to smooth data producing trend indicators.

Definition

MovingAverage MovingAverage(DataSeries source, int periods, MovingAverageType maType)
api.Indicators.MovingAverage(source: DataSeries, periods: int, maType: MovingAverageType) -> MovingAverage

Parameters

Name C# type Python type Description
source DataSeries DataSeries The source data used for the MA calculation.
periods int int The periods used in the calculation.
maType MovingAverageType MovingAverageType Method of calculation of MA.

Returns MovingAverage — Moving Average indicator instance

Examples

var ma = Indicators.MovingAverage(Bars.ClosePrices, 50, MovingAverageType.Exponential);
Print("EMA(50) last value: {0}", ma.Result.LastValue);
ma = api.Indicators.MovingAverage(api.Bars.ClosePrices, 50, MovingAverageType.Exponential)
api.Print(f"EMA(50) last value: {ma.Result.LastValue}")