Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
MACD for BTC/USDT using technicalindicators
node v8.17.0
version:
3.0.0
endpoint
share
tweet
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