More Information about:
Link: 1) http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_averages




Calculation:

Exponentially smoothed moving average is calculated by adding the moving average of a certain share of the current closing price to the previous value. With exponentially smoothed moving averages, the latest prices are of more value. P-percent exponential moving average will look like:

EMA = (CLOSE(i)*P)+(EMA(i-1)*(1-P))

Where:

CLOSE(i) - the price of the current period closure;
EMA(i-1) _ Exponentially Moving Average of the previous period closure;
P � the percentage of using the price value.



Source Code "EMA - Eponential Moving Average":

function init()
{
   EMA.createParameter("Period", 32);

   EMA.createBuffer("EMA");
   EMA.setBufferColor("EMA", "lime");
   EMA.setBufferDrawStyle("EMA", DrawStyle.LINE);

   EMA.setAutoChangeMaxMin("EMA");
}

function start()
{
   EMA.label = "EMA(" + EMA.parameter("Period") + ")";

   var emaBuf = Shared.ema(EMA.parameter("Period"), Shared.close());

   EMA.setBufferData("EMA", emaBuf);
}