-
-
Notifications
You must be signed in to change notification settings - Fork 977
Expand file tree
/
Copy pathindicator-data.js
More file actions
23 lines (20 loc) 路 975 Bytes
/
Copy pathindicator-data.js
File metadata and controls
23 lines (20 loc) 路 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Indicator values with the high-level data API.
// Pine indicators (STD;..., PUB;..., USER;...) need an account: set SESSION and SIGNATURE.
// Run: npm run build && node --env-file=.env examples/indicator-data.js
import { getIndicatorData } from '@mathieuc/tradingview/data';
const credentials = process.env.SESSION
? { session: process.env.SESSION, signature: process.env.SIGNATURE }
: undefined;
// A built-in study works without an account.
const volume = await getIndicatorData({ symbol: 'BINANCE:BTCEUR', indicator: 'Volume@tv-basicstudies-241', count: 5 });
console.log('Volume rows:', volume.values);
if (credentials) {
const rsi = await getIndicatorData({
symbol: 'BINANCE:BTCEUR',
timeframe: '60',
indicator: 'STD;RSI',
inputs: { Length: 21 }, // Input ID, number, inline name or internal ID
credentials,
});
console.log('Last RSI row:', rsi.values.at(-1));
} else console.log('Set SESSION and SIGNATURE to run a Pine indicator');