debut-js / Indicators

Technical indicators for cryptocurrencies, stocks and forex. To work with historical and real price data. One of the most efficient Javascript library implementations. The library has such indicators as: Relative Strength Index (RSI), Moving Average C / D (MACD), Average Directional Index (ADX), Stochastic Oscillator, Bollinger Bands, Average True Range (ATR) and many others

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

smaSlowValue always undefined

mmaestrini opened this issue · comments

commented

HI, first off thanks for this. I wish I could help on docs - maybe if i get around to understand how this work i might document it :D

I am trying your AO example 1:1 but it's not working. I am passing a dataset i get from tradinview of btc but I get nothing, the result is undefined and I noticed inside the nextValue method , smaFast value do get a value after a couple of entries, but the slow one returns always undefined... Why is that?

commented

This is my code

`const adapter = new TvApiAdapter();

    const fastPeriod = 5;
    const slowPeriod = 34;
    const ao = new indicators.AO(fastPeriod, slowPeriod);
    const stochRSI = new indicators.Stochastic();
    chart.setMarket(symbol, {
      type: 'HeikinAshi',
      timeframe: tf,
      range: parseInt(size),
    });

    chart.onSymbolLoaded(() => {
      console.log(chart.infos.name, 'loaded !');
    });

    chart.onUpdate(() => {
      // console.log('OK', chart.periods);
      chart.periods.forEach((entry) => {
        // console.log(entry);
        const o = entry.open;
        const h = entry.max;
        const l = entry.min;
        const c = entry.close;
        const v = entry.volume;
        const aoValue = ao.nextValue(h, l);
        const stochRsi = stochRSI.nextValue(h, l, c);
        console.log(stochRSI);
        // console.log(aoValue); // Accelerator Oscillator calculated value for current candle
      });
      client.end();
    });`

I am not sure how to use this honestly. I would have assumed that passing a dataset to stochastic i would have gotten the stoch rsi value in return but given im not an expert im not sure how to interpret the "fill" smaPeriod, etc etc

Hope you can provide some guidance..

Hi! Can you try to update to latest release, may that helps to you

If does not help, please create demo stand for me with some kind of data (OHLC) and calculations, which i can use as unit test for debugging calculations, thanks

commented

will try in a bit! thanks

can i close the issue?

Inactivity close