'Why am I getting different values for MACD, and ADX using the tulind npm package compared to those of Trading View?
I have a basic algorithmic trading system that requires a few technical indicator values to generate buy/sell signals. To compute these signals the library I found on npm was tulind. I am able to compute RSI, ATR values with reasonable accuracy when comparing the values to those in TradingView for the same parameters or my brokers terminal. But for some reason the values for MACD and ADX are way off.
ADX (tulind ADX doc) MACD tulind MACD doc
Reference OHLC Values for ETH/USDT (interval 15m, 60 data points)
For the ADX and MACD Values I have shown them side by side, hopefully easier to read:
LHS Trading View || RHS Tulind
{
PK: 'Ethereum-USDT',
SK: '1644466500000',
open: 3185.11,
high: 3186.55,
low: 3179.61,
close: 3182.98,
volume: 1962.7845,
time: 'Thu Feb 10 2022 04:15:00 GMT+0000 (Coordinated Universal Time)',
adx: <TradingViewValue> || <TulindValue>,
macd: [tradingViewMacd, TradingViewSignal, TradingViewHist] || [ tulindMacd, tulindSignal, tulindSignal ],
},
But the values for ADX and MACD according to TradingView are listed below. I have removed the Bollinger Band, RSI, ATR and VWMA values for simplicity.
Also the initial few values will be undefined because MACD and ADX require a trailing interval to calculate their respective averages (EMA, SMA) for the given period. tulind MACD uses EMA, and even the Trading view chart used EMA.
TradingView MACD(12,26,close, 9) ADX(14,14)
[
{
PK: 'Ethereum-USDT',
SK: '1644441300000',
open: 3254.33,
high: 3256.8,
low: 3245.05,
close: 3253.56,
volume: 1957.6724,
time: 'Wed Feb 09 2022 21:15:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644442200000',
open: 3253.56,
high: 3256,
low: 3247.01,
close: 3249.01,
volume: 2060.9558,
time: 'Wed Feb 09 2022 21:30:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644443100000',
open: 3249,
high: 3249.99,
low: 3234.64,
close: 3236.08,
volume: 3263.5295,
time: 'Wed Feb 09 2022 21:45:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644444000000',
open: 3236.09,
high: 3247,
low: 3234.7,
close: 3236.85,
volume: 3090.103,
time: 'Wed Feb 09 2022 22:00:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644444900000',
open: 3237.01,
high: 3245.59,
low: 3230.83,
close: 3233.53,
volume: 2708.5547,
time: 'Wed Feb 09 2022 22:15:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644445800000',
open: 3233.52,
high: 3245.39,
low: 3232.34,
close: 3242.5,
volume: 1597.7138,
time: 'Wed Feb 09 2022 22:30:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644446700000',
open: 3242.5,
high: 3254.57,
low: 3241.18,
close: 3251.02,
volume: 1700.1006,
time: 'Wed Feb 09 2022 22:45:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644447600000',
open: 3251.01,
high: 3251.03,
low: 3239.5,
close: 3242.37,
volume: 2438.6868,
time: 'Wed Feb 09 2022 23:00:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644448500000',
open: 3242.38,
high: 3245.76,
low: 3232.13,
close: 3236.62,
volume: 2145.4951,
time: 'Wed Feb 09 2022 23:15:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644449400000',
open: 3236.47,
high: 3240,
low: 3231.41,
close: 3234.82,
volume: 2475.7506,
time: 'Wed Feb 09 2022 23:30:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644450300000',
open: 3234.46,
high: 3244.75,
low: 3232.95,
close: 3243.94,
volume: 3475.246,
time: 'Wed Feb 09 2022 23:45:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644451200000',
open: 3243.6,
high: 3248.98,
low: 3233.08,
close: 3235.71,
volume: 3388.5759,
time: 'Thu Feb 10 2022 00:00:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644452100000',
open: 3235.7,
high: 3235.82,
low: 3211.27,
close: 3224.74,
volume: 5900.3456,
time: 'Thu Feb 10 2022 00:15:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644453000000',
open: 3224.74,
high: 3229.21,
low: 3220.03,
close: 3221.87,
volume: 2284.579,
time: 'Thu Feb 10 2022 00:30:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644453900000',
open: 3221.87,
high: 3224.36,
low: 3213.58,
close: 3220.09,
volume: 1912.0115,
time: 'Thu Feb 10 2022 00:45:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644454800000',
open: 3220.08,
high: 3225.99,
low: 3217.4,
close: 3225.78,
volume: 2333.8357,
time: 'Thu Feb 10 2022 01:00:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644455700000',
open: 3225.78,
high: 3227.94,
low: 3213,
close: 3214.23,
volume: 1930.1322,
time: 'Thu Feb 10 2022 01:15:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644456600000',
open: 3214.24,
high: 3227.95,
low: 3207.18,
close: 3225.73,
volume: 2239.9224,
time: 'Thu Feb 10 2022 01:30:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644457500000',
open: 3225.74,
high: 3228.92,
low: 3219.29,
close: 3224.27,
volume: 1529.6633,
time: 'Thu Feb 10 2022 01:45:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644458400000',
open: 3224.28,
high: 3229.26,
low: 3215.67,
close: 3225.8,
volume: 2698.5158,
time: 'Thu Feb 10 2022 02:00:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644459300000',
open: 3225.79,
high: 3228.58,
low: 3220.86,
close: 3228.29,
volume: 1852.1316,
time: 'Thu Feb 10 2022 02:15:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644460200000',
open: 3228.3,
high: 3229,
low: 3220,
close: 3221.53,
volume: 1552.3685,
time: 'Thu Feb 10 2022 02:30:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644461100000',
open: 3221.54,
high: 3224.8,
low: 3184.01,
close: 3186.58,
volume: 8794.0948,
time: 'Thu Feb 10 2022 02:45:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644462000000',
open: 3186.58,
high: 3189.99,
low: 3170.87,
close: 3177.58,
volume: 6907.7173,
time: 'Thu Feb 10 2022 03:00:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644462900000',
open: 3177.58,
high: 3186.24,
low: 3175.01,
close: 3185.17,
volume: 2376.6198,
time: 'Thu Feb 10 2022 03:15:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [ undefined, undefined, undefined ],
},
{
PK: 'Ethereum-USDT',
SK: '1644463800000',
open: 3185.17,
high: 3188.4,
low: 3179.04,
close: 3180.4,
volume: 2018.936,
time: 'Thu Feb 10 2022 03:30:00 GMT+0000 (Coordinated Universal Time)',
adx: undefined,
macd: [-10.2796, -3.8704, -6.4092] || [ -17.149096689322505, -17.149096689322505, 0 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644464700000',
open: 3180.39,
high: 3183.52,
low: 3176.24,
close: 3179.6,
volume: 1924.7523,
time: 'Thu Feb 10 2022 03:45:00 GMT+0000 (Coordinated Universal Time)',
adx: 34.5116 || 35.63379452241485,
macd: [-11.5489, -5.4061, -6.1428] || [ -17.215103649811226, -17.16229808142025, -0.052805568390976276 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644465600000',
open: 3179.59,
high: 3186.5,
low: 3173.82,
close: 3185.11,
volume: 2120.8285,
time: 'Thu Feb 10 2022 04:00:00 GMT+0000 (Coordinated Universal Time)',
adx: 35.8437 || 36.02667215190461,
macd: [-11.9722, -6.7193, -5.2529] || [ -17.278081706434932, -17.185454806423188, -0.09262690001174434 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644466500000',
open: 3185.11,
high: 3186.55,
low: 3179.61,
close: 3182.98,
volume: 1962.7845,
time: 'Thu Feb 10 2022 04:15:00 GMT+0000 (Coordinated Universal Time)',
adx: 37.0734 || 36.6077226930339,
macd: [-12.3373, -7.8429, -4.4944] || [ -17.290719784258272, -17.206507801990206, -0.08421198226806581 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644467400000',
open: 3182.98,
high: 3197.12,
low: 3173.48,
close: 3173.63,
volume: 4032.4646,
time: 'Thu Feb 10 2022 04:30:00 GMT+0000 (Coordinated Universal Time)',
adx: 36.7959 || 36.19009713074871,
macd: [-13.2287, -8.9201, -4.3086] || [ -16.78213587537357, -17.121633416666878, 0.33949754129330856 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644468300000',
open: 3173.63,
high: 3175.96,
low: 3158.73,
close: 3168.85,
volume: 8146.4892,
time: 'Thu Feb 10 2022 04:45:00 GMT+0000 (Coordinated Universal Time)',
adx: 37.3173 || 33.64438345463229,
macd: [-14.1576, -9.9676, -4.1900] || [ -15.83496274841491, -16.864299283016486, 1.0293365346015761 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644469200000',
open: 3168.86,
high: 3168.91,
low: 3156.45,
close: 3164.53,
volume: 3189.7873,
time: 'Thu Feb 10 2022 05:00:00 GMT+0000 (Coordinated Universal Time)',
adx: 37.9071 || 31.280506469667046,
macd: [-15.0686, -10.9878, -4.0808] || [ -14.210854546424343, -16.333610335698058, 2.1227557892737146 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644470100000',
open: 3164.54,
high: 3170.49,
low: 3160.26,
close: 3166.63,
volume: 2316.156,
time: 'Thu Feb 10 2022 05:15:00 GMT+0000 (Coordinated Universal Time)',
adx: 38.2535 || 29.57072684463347,
macd: [-15.4432, -11.8789, -3.5643] || [ -12.614277358962227, -15.589743740350892, 2.9754663813886655 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644471000000',
open: 3166.63,
high: 3169.36,
low: 3160.45,
close: 3169.36,
volume: 1960.3858,
time: 'Thu Feb 10 2022 05:30:00 GMT+0000 (Coordinated Universal Time)',
adx: 38.5751 || 27.98307433567372,
macd: [-15.3428, -12.5717, -2.7712] || [ -11.630307925031502, -14.797856577287014, 3.167548652255512 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644471900000',
open: 3169.35,
high: 3176.47,
low: 3166.68,
close: 3174.93,
volume: 2710.4344,
time: 'Thu Feb 10 2022 05:45:00 GMT+0000 (Coordinated Universal Time)',
adx: 37.9379 || 26.0288985832429,
macd: [-14.6451, -12.9863, -1.6587] || [ -10.665820993446687, -13.971449460518949, 3.305628467072262 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644472800000',
open: 3174.92,
high: 3180.61,
low: 3172.6,
close: 3175.44,
volume: 2115.9863,
time: 'Thu Feb 10 2022 06:00:00 GMT+0000 (Coordinated Universal Time)',
adx: 36.8422 || 24.58860772893082,
macd: [-13.8908, -13.1672, -0.7236] || [ -9.429752657311838, -13.063110099877527, 3.633357442565689 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644473700000',
open: 3175.44,
high: 3176.58,
low: 3168,
close: 3170.05,
volume: 1655.5229,
time: 'Thu Feb 10 2022 06:15:00 GMT+0000 (Coordinated Universal Time)',
adx: 36.1627 || 23.621832547339846,
macd: [-13.5715, -13.2481, -0.3234] || [ -8.921059210631483, -12.234699922028318, 3.3136407113968342 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644474600000',
open: 3170.06,
high: 3189.7,
low: 3168,
close: 3188.62,
volume: 3140.3853,
time: 'Thu Feb 10 2022 06:30:00 GMT+0000 (Coordinated Universal Time)',
adx: 34.0939 || 23.78607475420796,
macd: [-11.6853, -12.9355, 1.2502] || [ -7.745737072059001, -11.336907352034455, 3.5911702799754543 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644475500000',
open: 3188.61,
high: 3189.18,
low: 3178.17,
close: 3179.41,
volume: 2356.501,
time: 'Thu Feb 10 2022 06:45:00 GMT+0000 (Coordinated Universal Time)',
adx: 32.1729 || 24.158005819935493,
macd: [-10.8091, -12.5102, 1.7012] || [ -4.113250498545767, -9.892175981336717, 5.7789254827909495 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644476400000',
open: 3179.41,
high: 3190.67,
low: 3177.9,
close: 3189.84,
volume: 2920.8196,
time: 'Thu Feb 10 2022 07:00:00 GMT+0000 (Coordinated Universal Time)',
adx: 30.2329 || 24.503370380968203,
macd: [-9.1674, -11.8417, 2.6743] || [ -0.7039338620124909, -8.054527557471872, 7.350593695459381 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644477300000',
open: 3189.84,
high: 3190.07,
low: 3181.04,
close: 3182.42,
volume: 3739.462,
time: 'Thu Feb 10 2022 07:15:00 GMT+0000 (Coordinated Universal Time)',
adx: 28.4315 || 24.30721504411624,
macd: [-8.3686, -11.1471, 2.7785] || [ 1.7978105994093312, -6.084059926095631, 7.881870525504962 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644478200000',
open: 3182.42,
high: 3184.77,
low: 3178.4,
close: 3181.81,
volume: 2386.8,
time: 'Thu Feb 10 2022 07:30:00 GMT+0000 (Coordinated Universal Time)',
adx: 27.0317 || 24.125070802753708,
macd: [-7.6960, -10.4568, 2.7608] || [ 3.629831812958855, -4.141281578284734, 7.771113391243589 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644479100000',
open: 3181.81,
high: 3195.62,
low: 3179.6,
close: 3189.9,
volume: 2764.0809,
time: 'Thu Feb 10 2022 07:45:00 GMT+0000 (Coordinated Universal Time)',
adx: 25.6448 || 22.809731605204448,
macd: [-6.4360, -9.6527, 3.2167] || [ 5.138922884216754, -2.2852406857844363, 7.42416357000119 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644480000000',
open: 3189.9,
high: 3208.02,
low: 3185.4,
close: 3201.34,
volume: 4990.469,
time: 'Thu Feb 10 2022 08:00:00 GMT+0000 (Coordinated Universal Time)',
adx: 25.3920 || 21.58834520748014,
macd: [-4.4629, -8.6147, 4.1518] || [ 5.405132856545606, -0.7471659773184278, 6.152298833864034 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644480900000',
open: 3201.34,
high: 3202.74,
low: 3191.19,
close: 3194.2,
volume: 3312.1242,
time: 'Thu Feb 10 2022 08:15:00 GMT+0000 (Coordinated Universal Time)',
adx: 25.1573 || 20.454200695307563,
macd: [-3.4357, -7.5789, 4.1432] || [ 6.4198827026530125, 0.6862437586758603, 5.7336389439771525 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644481800000',
open: 3194.2,
high: 3199.41,
low: 3190.53,
close: 3196.17,
volume: 2506.9587,
time: 'Thu Feb 10 2022 08:30:00 GMT+0000 (Coordinated Universal Time)',
adx: 24.8557 || 19.02835395564676,
macd: [-2.4347, -6.5501, 4.1154] || [ 6.7187560887500695, 1.8927462246907023, 4.826009864059367 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644482700000',
open: 3196.18,
high: 3199.07,
low: 3193.12,
close: 3198.74,
volume: 2649.5968,
time: 'Thu Feb 10 2022 08:45:00 GMT+0000 (Coordinated Universal Time)',
adx: 24.5756 || 18.15373143146654,
macd: [-1.4176, -5.5236, 4.1060] || [ 7.0116592825702355, 2.9165288362666093, 4.095130446303626 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644483600000',
open: 3198.75,
high: 3200.3,
low: 3183.62,
close: 3186.05,
volume: 3959.3863,
time: 'Thu Feb 10 2022 09:00:00 GMT+0000 (Coordinated Universal Time)',
adx: 23.1236 || 17.2077773430096,
macd: [-1.6169, -4.7422, 3.1253] || [ 7.378323251782604, 3.808887719369808, 3.5694355324127955 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644484500000',
open: 3186.05,
high: 3210.76,
low: 3185.28,
close: 3204.69,
volume: 4850.4748,
time: 'Thu Feb 10 2022 09:15:00 GMT+0000 (Coordinated Universal Time)',
adx: 22.7370 || 16.75574487238784,
macd: [-0.2677, -3.8473, 3.5797 ][ 8.406356660993424, 4.7283815076945315, 3.6779751532988927 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644485400000',
open: 3204.69,
high: 3205.7,
low: 3198.18,
close: 3203.24,
volume: 2249.5761,
time: 'Thu Feb 10 2022 09:30:00 GMT+0000 (Coordinated Universal Time)',
adx: 22.3780 || 16.32333980801485,
macd: [0.6768, -2.9425, 3.6193] || [ 9.737326416548967, 5.730170489465419, 4.007155927083549 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644486300000',
open: 3203.23,
high: 3217.02,
low: 3201.08,
close: 3214.39,
volume: 2621.1701,
time: 'Thu Feb 10 2022 09:45:00 GMT+0000 (Coordinated Universal Time)',
adx: 22.9264 || 15.763785292968082,
macd: [2.2985, -1.8943, 4.1928] || [ 9.990256464668164, 6.582187684505968, 3.4080687801621963 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644487200000',
open: 3214.36,
high: 3253.19,
low: 3211.74,
close: 3247.96,
volume: 16778.6311,
time: 'Thu Feb 10 2022 10:00:00 GMT+0000 (Coordinated Universal Time)',
adx: 25.1366 || 15.731200011587605,
macd: [6.2208, -0.2713, 6.4921] || [ 10.211732329774804, 7.308096613559735, 2.903635716215069 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644488100000',
open: 3247.96,
high: 3269,
low: 3244,
close: 3255.1,
volume: 11252.5066,
time: 'Thu Feb 10 2022 10:15:00 GMT+0000 (Coordinated Universal Time)',
adx: 27.6440 || 16.114666197591212,
macd: [9.7926, 1.7415, 8.0511] ||[ 10.702235740005108, 7.98692443884881, 2.715311301156298 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644489000000',
open: 3255.11,
high: 3260.41,
low: 3250.11,
close: 3253.38,
volume: 3587.5641,
time: 'Thu Feb 10 2022 10:30:00 GMT+0000 (Coordinated Universal Time)',
adx: 29.9723 || 16.736416879940577,
macd: [12.3421, 3.8616, 8.4805] || [ 11.616243894223317, 8.712788329923711, 2.9034555642996054 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644489900000',
open: 3253.38,
high: 3253.39,
low: 3241.63,
close: 3246.94,
volume: 3085.863,
time: 'Thu Feb 10 2022 10:45:00 GMT+0000 (Coordinated Universal Time)',
adx: 31.2287 || 16.310643810901286,
macd: [13.6853, 5.263, 7.859] || [ 11.565200061667383, 9.283270676272446, 2.281929385394937 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644490800000',
open: 3246.93,
high: 3253.12,
low: 3236.66,
close: 3251.05,
volume: 3597.6981,
time: 'Thu Feb 10 2022 11:00:00 GMT+0000 (Coordinated Universal Time)',
adx: 31.8939 || 15.754838473465064,
macd: [14.9095, 7.6430, 7.2665] || [ 10.722208347626747, 9.571058210543306, 1.151150137083441 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644491700000',
open: 3251.05,
high: 3258.6,
low: 3243.96,
close: 3252.86,
volume: 3892.0154,
time: 'Thu Feb 10 2022 11:15:00 GMT+0000 (Coordinated Universal Time)',
adx: 32.6735 || 15.369297399453375,
macd: [15.8431, 9.2830, 6.5601] || [ 10.18778126855159, 9.694402822144962, 0.4933784464066271 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644492600000',
open: 3252.87,
high: 3283.66,
low: 3251.62,
close: 3266.12,
volume: 8840.7113,
time: 'Thu Feb 10 2022 11:30:00 GMT+0000 (Coordinated Universal Time)',
adx: 34.3005 || 15.290750549328468,
macd: [17.4148, 10.8624, 6.5524] || [ 9.595225438357375, 9.674567345387445, -0.07934190703007005 ],
},
{
PK: 'Ethereum-USDT',
SK: '1644493500000',
open: 3266.13,
high: 3268.8,
low: 3237.19,
close: 3248.05,
volume: 6287.5344,
time: 'Thu Feb 10 2022 11:45:00 GMT+0000 (Coordinated Universal Time)',
rsi: 61.54697940553924,
atr: 17.630676240671082,
vwma: 3235.228601024122,
adx: 34.54 || 15.746399039834964,
macd: [17.0376, 12.0974, 4.9402] || [ 9.991132130685855, 9.737880302447127, 0.25325182823872794 ],
bbands: [ 3171.495956221555, 3199.042743755336, 3226.5895312891166 ]
},
{
PK: 'Ethereum-USDT',
SK: '1644494400000',
open: 3248.05,
high: 3261.1,
low: 3243.64,
close: 3256.97,
volume: 4512.1496,
time: 'Thu Feb 10 2022 12:00:00 GMT+0000 (Coordinated Universal Time)',
adx: 34.764 || 15.913784718103779,
macd: [17.1812, 13.1142, 4.0671][ 10.531263531058812, 9.896556948169465, 0.634706582889347 ],
}
]
I am literally entering the same values. The OHLC values match but the result from the tulind library for the MACD and ADX values are not even close. What am I doing wrong?
below is the function to compute ADX: returns a promise that's awaited in the importing function
const tulind = require("tulind");
const adx = async (ohlc, period) => {
const high = ohlc.map((item) => item.high);
const low = ohlc.map((item) => item.low);
const close = ohlc.map((item) => item.close);
console.log("closeADX: ", close);
const adx = tulind.indicators.adx.indicator([high,low,close], [period]);
return adx;
}
module.exports = adx;
and this one calculates MACD returns a promise that's awaited in the importing function
const tulind = require("tulind");
const macd = async (ohlc, shortPeriod, longPeriod, signalPeriod) => {
const close = ohlc.map((item) => item.close);
const macd = tulind.indicators.macd.indicator([close], [shortPeriod, longPeriod, signalPeriod]);
return macd;
}
module.exports = macd;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
