Skip to content

Averages

Ruben edited this page Sep 26, 2017 · 7 revisions

Averages

All average functions take as first parameter the list of values in ohlc format (open, high, low, close).

  • The last parameter indicates the target attribute, e.g. the Moving Average uses by default the close value, but other can be provided.
  • The returned list is a copy of the original input plus the average values.

MA (Moving Average)

Appends the ma attribute.

var maList = ma ({h:34.4}, {h:35.4}, ..., {h:40.3});    
console.log(maList, 2, ["h"]);
{c:34.4}, {c:35.4}, ... {c:40.3, ma:40}

EMA (Exponential Moving Average)

Appends the ema attribute.

var emaList = ema ({c:34.4}, {c:35.4}, ..., {c:40.3});
console.log(emaList, 4);
{c:34.4}, {c:35.4}, ... {c:40.3, ema:44}

WMA (Weighted Moving Average)

Appends the wma attribute.

var wmaList = wma ({c:34.4}, {c:35.4}, ..., {c:40.3});
console.log(wmaList, 4);
{c:34.4}, {c:35.4}, ... {c:40.3, wma:32.2}
Clone this wiki locally