Indicators
Ruben edited this page Nov 6, 2017
·
9 revisions
Takes as input a list of ohlcv data (ohlc values plus _volume).
Returns the input list enriched with the mfi attribute.
var values = [...,
{h:4161, l:4081, c:4151, v:300},
{h:4181, l:4110, c:4117, v:255},
{h:4158, l:4104, c:4111, v:310}];
var mfiResult = mfi (values, 14); // window size = 14;
console.log(mfiResult);
[...., {h:4181, l:4110, c:4117, v:255, mfi:72.71},
{h:4158, l:4104, c:4111, v:310, mfi:65.73}];
Takes as input a list of closing values.
Returns the input list with the macd attribute containing hist, signal and line values.
var closingValues = [..., {c:187.74},{c:188.76},{c:190.09}];
var macdResults = macd (closingValues);
console.log(macdResults);
[..., {c: 190.09,
macd: { line: 1.1606644676243283, signal: 1.073581926639526, hist: 0}}]
Takes as input a list of _closing_values.
Returns the input list enriched with the mom attribute.
var values = [{c:196.35},{c:195.27},{c:193.99},{c:193.14},
{c:192.87},{c:192.32},{c:192.88},{c:194.45}, {c:192.62}, {c:192.50}];
var momValues = mom(values, 1); // window size = 1
console.log(momValues);
[...,
{ c: 192.88}, { c: 194.45, mom: 1.579999999999984 },
{ c: 192.62, mom: 0.30000000000001137 }, { c: 192.5, mom: -0.37999999999999545 } ]
Takes as input a list of closing values.
Returns the input list with the new roc values appended.
var values = [{c:196.35},{c:195.27},{c:193.99},{c:193.14},
{c:192.87},{c:192.32},{c:192.88},{c:194.45}, {c:192.62}, {c:192.50}];
var rocValues = roc (values, 1); // window size = 1
console.log(rocValues);
[..., { c: 192.62, roc: 0.0015599001663894102 },
{ c: 192.5, roc: -0.0019701368726669196 } ]
Takes as input a list of closing values.
Returns the input list enriched with the rsi attribute
var values = [..., {c:44.18}, {c:44.22}, {c:44.57},{c:43.42}, {c:42.66},
{c:43.13}];
var rsiValues = rsi (values, 14); // window size = 14
console.log(rsiValues);
[..., {c: 42.66, rsi: 33.09048257272339 },
{c: 43.13, rsi: 37.788771982057824 } ]
Returns the input list enriched with the atr attribute
var values = [..., {h:49.88, l:49.43, c:49.75}, {h:50.19, l:49.73, c:50.03},
{h:50.36, l:49.26, c:50.31}, {h:50.57, l:50.09, c:50.52}]
var atrValues = atr(values);
console.log(atrValues);
[..., { h: 50.57, l: 50.09, c: 50.52,
at: { tr: 0.4799999999999969, atr: 0.5851749271137028 } } ];
Returns the ADX values and -DI +DI indicators (dmn and dmp respectively).
Notice that the first ADX value appears in the 29th result.
var values = [...,{h:30.20,l:29.41,c:29.87},{h:30.28,l:29.32,c:30.24}...];
var adxValues = adx(values);
console.log(adxValues);
[...,
{dmp: 0, dmn: 0.18, tr: 0.69, tr14: 13.85, dmp14: 3.63,
dmn14: 2.9, di14p: 26.22, di14n: 20.92, diff: 5.3, sum: 47.13, dx: 11.26, adx: 21.59},
...];