UNPKG

@mathieuc/tradingview

Version:

Tradingview instant stocks API, indicator alerts, trading bot, and more !

36 lines (28 loc) 937 B
const TradingView = require('../main'); /** * This example tests fetching chart data of a number * of candles before or after a timestamp */ if (!process.env.SESSION || !process.env.SIGNATURE) { throw Error('Please set your sessionid and signature cookies'); } const client = new TradingView.Client({ token: process.env.SESSION, signature: process.env.SIGNATURE, }); const chart = new client.Session.Chart(); chart.setMarket('BINANCE:BTCEUR', { timeframe: '240', range: 2, // Can be positive to get before or negative to get after to: 1700000000, }); // This works with indicators TradingView.getIndicator('STD;Supertrend').then(async (indic) => { console.log(`Loading '${indic.description}' study...`); const SUPERTREND = new chart.Study(indic); SUPERTREND.onUpdate(() => { console.log('Prices periods:', chart.periods); console.log('Study periods:', SUPERTREND.periods); client.end(); }); });