How to interpret TA-LIB result arrays? (Technical Analysis Library)

1.5k views Asked by At

I'm developing a financial technical analysis algortithm with node-talib, a wrapper of TALIB (Technical Analysis Library).

Giving a marketdata array of 400 positions, I execute an ADX and I get an array of 384 positions. What does it mean? What that array represent?

I add an example of the code:

const talib = require("node-talib")
// Load market data
var marketContents = fs.readFileSync('examples/marketdata.json','utf8'); 
var marketData = JSON.parse(marketContents);

// execute ADX indicator function with time period 9
talib.execute({
    name: "ADX",
    startIdx: 0,
    endIdx: marketData.close.length - 1,
    high: marketData.high,
    low: marketData.low,
    close: marketData.close,
    optInTimePeriod: 9
}, function (err, result) {

    // Show the result array
    console.log("ADX Function Results:");
    console.log(result);

});


where marketdata is an object of arrays like this: 

{
   "open": [
        448.36,
        448.45,
        447.49,
        (...) ],
  "close": [
        448.36,
        448.45,
        447.49,
        (...) ],
   "min": [
        448.36,
        448.45,
        447.49,
        (...) ],
   "max": [
        448.36,
        448.45,
        447.49,
        (...) ],
  "volume": [
        448.36,
        448.45,
        447.49,
        (...) ]
   }

And the result is an array of floats (always less than marketdata.open/close/min/max length).

Thanks

1

There are 1 answers

1
truf On

You'd better to read official c++ docs In a nutshell result array is always same size or less than input array. It is less, for example, for 5-day average. If you apply it to 60 days input data you'll get only 56 results. Because 5-day average require 5 values to be calculated and for first 4 days it's undefined. So result array contain data corresponding to last n input values where n <= input array size depending on indicator you apply.