IIndicatorsAccessor.ExponentialMovingAverage
method · IIndicatorsAccessor · cAlgo.API.Internals
DesktopCLICloud
The Exponential Moving Average smoothes the price data producing a trend indicator.
Definition
ExponentialMovingAverage ExponentialMovingAverage(DataSeries source, int periods)
api.Indicators.ExponentialMovingAverage(source: DataSeries, periods: int) -> ExponentialMovingAverage
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
source | DataSeries | DataSeries | The source data used for the EMA calculation. |
periods | int | int | The periods used in the calculation. |
Returns ExponentialMovingAverage — Exponential Moving Average indicator instance
Examples
var ema = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 20);
if (Bars.ClosePrices.Last(1) > ema.Result.Last(1))
Print("Last bar closed above EMA(20): {0}", ema.Result.Last(1));
ema = api.Indicators.ExponentialMovingAverage(api.Bars.ClosePrices, 20)
if api.Bars.ClosePrices.Last(1) > ema.Result.Last(1):
api.Print(f"Last bar closed above EMA(20): {ema.Result.Last(1)}")