Exponential Moving Average


An exponential moving average (EMA), sometimes also called an exponentially weighted moving average (EWMA), applies weighting factors which decrease exponentially. The weighting for each older data point decreases exponentially, giving much more importance to recent observations while still not discarding older observations entirely.

AnyChart Stock allows you to add EMA with desired period to any of your charts.

Mathematical description of the indicator: Exponential Moving Average (EMA) Mathematical Description.

Adding Indicator

EMA indicator is added using ema() method, it requires a mapping with the "value" field in it:

// create data table on loaded data
var dataTable = anychart.data.table();

// add data to a table

// map loaded data
var mapping = dataTable.mapAs({'value': 4});

// create stock chart
chart = anychart.stock();

// create plot on the chart
var plot = chart.plot(0);

// create EMA indicators with period 20
var ema20 = plot.sma(mapping, 20).series();

Here is a live sample:


Indicator Parameters

EMA indicator need three parameters: mapping with the "value" field in it, period and a type of series to be displayed as:

var ema10 = plot.ema(mapping, 10, "column");


Indicator visualization depends on the series you chose to display it with, here is a sample where EMA with different parameters and settings is added to different plots:

// create EMA indicator with period 20 and show as line on the first plot
var ema20 = plot_0.ema(mapping, 20).series();

// create EMA indicator with period 50 and show as column on the second plot
var ema50 = plot_1.ema(mapping, 50, "column").series();

Live sample: