Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

MACD for BTC/USDT using technicalindicators

node v8.17.0
version: 3.0.0
endpointsharetweet
Retrieve OHLCV (Open, High, Low, Close, Volume) from Binance
const ccxt = require('ccxt') const retrieveKlines = async (coin, timeframe) => { timeframe = timeframe || '1d' return new Promise(async resolve => { const exchange = new ccxt.binance() const klines = await exchange.fetchOHLCV(coin, timeframe) resolve(klines) }) }
Retrieve the MACD results for a given coin using kline closes
const technicalindicators = require('technicalindicators'), MACD = technicalindicators.MACD; const retrieveMACD = (klines) => { const closes = klines.map(kline => kline[4]) var macdInput = { values : closes, fastPeriod : 12, slowPeriod : 26, signalPeriod : 9 , SimpleMAOscillator: false, SimpleMASignal : false } const macdResults = MACD.calculate(macdInput) return macdResults; }
// Use https://www.tradingview.com/chart/q8XPqAv3/ to compare const coin = "BTC/USDT" const klines = await retrieveKlines(coin) retrieveMACD(klines)
Loading…

no comments

    sign in to comment