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

How to work with ccxt OHLCV?

Mangdar opened this issue · comments

how to work with data like this? please show me some example with ema or sma

[
[ 1635435180000, 4177.79, 4181.47, 4176.42, 4181.01, 141.193 ],
[ 1635435240000, 4181.01, 4184.96, 4180.5, 4184.91, 593.7 ],
[ 1635435300000, 4184.92, 4185.2, 4182.08, 4183.29, 936.606 ],
[ 1635435360000, 4183.29, 4184.92, 4183.28, 4184.29, 270.19 ],
[ 1635435420000, 4184.28, 4184.7, 4182.03, 4183.48, 259.201 ]
]

thats array is [time, open, high, low, close], just get each number from array by index.

for example:

[
[ 1635435180000, 4177.79, 4181.47, 4176.42, 4181.01, 141.193 ],
[ 1635435240000, 4181.01, 4184.96, 4180.5, 4184.91, 593.7 ],
[ 1635435300000, 4184.92, 4185.2, 4182.08, 4183.29, 936.606 ],
[ 1635435360000, 4183.29, 4184.92, 4183.28, 4184.29, 270.19 ],
[ 1635435420000, 4184.28, 4184.7, 4182.03, 4183.48, 259.201 ]
]

// ohlc[0] - time
// ohlc[1] - open
// ...etc

data.forEach(ohlc => {
     const smaValue = sma.nextValue(ohlc[4]);
});