MACD
emorling opened this issue · comments
Some of the indicators simply return undefined values. See this simple example, why are all the values undefined?
const { MACD } = require('@debut/indicators');
const values = [127.75, 129.02, 132.75, 145.40, 148.98, 137.52, 147.38, 139.05, 137.23, 149.30, 162.45, 178.95, 200.35, 221.90, 243.23, 243.52, 286.42, 280.27, 277.35, 269.02, 263.23, 214.90];
const macd = new MACD();
values.forEach((value) => {
const nextValue = macd.nextValue(value);
console.log(nextValue);
});
Your example array has a length of 22. The default parameters for the MACD is
constructor(private periodEmaFast = 12, private periodEmaSlow = 26, private periodSi)
All the indicators will return undefined until you fill the minimum buffer required to generate a result.
Make sure you have enough data in your test array to generate a response.