definance
Financial utilities for calculating KDJ, MACD, RSI, DMI indicators by DeKuan, Inc.
Install
$ npm install definance.js
Testing
mocha
Usage
KDJ
const kdj = ; // Testing dataconst g_oSource = close : 1020170 1028360 1028510 1025024 1021526 1020641 1022439 1022111 1019405 1018930 1018597 1020070 1017051 1015926 1017010 1016063 1021685 1018495 1021397 1019874 1025368 1025156 low : 1011803 1020160 1027500 1023000 1017420 1019494 1020194 1019922 1019200 1016001 1017825 1018597 1016275 1013512 1015926 1015548 1015000 1017622 1017285 1019720 1019735 1022700 high : 1021808 1033000 1031000 1028754 1026019 1023669 1023220 1022788 1022750 1021250 1020000 1021290 1020638 1017058 1018158 1017500 1022908 1024527 1021848 1022249 1027026 1026315 ; // Array.<Number> array of closing prices.const arrClose = g_oSourceclose; // Array.<Number> array of low prices.const arrLow = g_oSourcelow; // Array.<Number> array of high prices.const arrHigh = g_oSourcehigh; // the size of time periods to get the highest / lowest prices. Defaults to 9.const nPeriod = 9; // the time periods to calculate the moving average for %K. Defaults to 3const nKSmaPeriod = 3; // the time periods to calculate the moving average for %D. Defaults to 3const nDSmaPeriod = 3; // will return a {Promise<{ K: Array, D: Array, J: Array, Ks: Array, Ds: Array}>};
will outputs
{ K:
[ null,
null,
null,
null,
null,
null,
null,
null,
45.28785519963499,
35.93537857280196,
29.72619255565715,
30.4528677520216,
23.795623154305733,
23.786035534001563,
27.868069836841446,
27.745739241521882,
47.49176712880241,
46.74061521705305,
55.02181126438695,
55.93374193234791,
66.53290851333185,
73.0761050589099 ],
D:
[ null,
null,
null,
null,
null,
null,
null,
null,
48.429285066545,
44.26464956863066,
39.418497230972825,
36.42995407132241,
32.218510432316855,
29.40768546621176,
28.89448025642166,
28.5115665847884,
34.838300099459744,
38.80573847199085,
44.21109606945622,
48.11864469042012,
54.2567326313907,
60.5298567738971 ],
J:
[ null,
null,
null,
null,
null,
null,
null,
null,
39.004995465814986,
19.27683658114455,
10.341583205025799,
18.49869511341997,
6.949848598283495,
12.542735669581162,
25.815248997681024,
26.21408455498885,
72.79870118748775,
62.61036870717743,
76.64324165424841,
71.56393641620348,
91.08526027721415,
98.16860162893552 ],
Ks:
[ null,
null,
null,
null,
null,
null,
null,
null,
11.954521866301654,
17.697996972680283,
23.467270479802792,
22.148154661751306,
19.898390874997343,
22.05140413233924,
23.426710898262808,
29.10002559559906,
50.172346465589136,
53.24107078260018,
67.93544588532417,
58.19337267362629,
72.35768276754142,
77.21711436454517 ],
Ds:
[ null,
null,
null,
null,
null,
null,
null,
null,
15.095951733211663,
27.07441125747898,
36.9831421093647,
32.038146293493575,
27.991561153994827,
26.01150881344297,
25.149909508382915,
26.466614870788295,
34.36852540238858,
40.65937386245911,
49.7513978700808,
52.56538947126264,
59.162820570022234,
65.18091850152989 ] }
Return values
K
D
J
Ks
the smooth value of K calculated by the Simple Moving Average with the time period {nKSmaPeriod}.
Ds
the smooth value of D calculated by the Simple Moving Average with the time period {nDSmaPeriod}.