-
-
Notifications
You must be signed in to change notification settings - Fork 403
/
Copy pathGraphicIndicator.js
42 lines (34 loc) · 1.16 KB
/
GraphicIndicator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const TradingView = require('../main');
/**
* This example tests an indicator that sends graphic data such
* as 'lines', 'labels', 'boxes', 'tables', 'polygons', etc...
*/
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: '5',
range: 10000,
});
// TradingView.getIndicator('USER;01efac32df544348810bc843a7515f36').then((indic) => {
// TradingView.getIndicator('PUB;5xi4DbWeuIQrU0Fx6ZKiI2odDvIW9q2j').then((indic) => {
TradingView.getIndicator('STD;Zig_Zag').then((indic) => {
const STD = new chart.Study(indic);
STD.onError((...err) => {
console.log('Study error:', ...err);
});
STD.onReady(() => {
console.log(`STD '${STD.instance.description}' Loaded !`);
});
STD.onUpdate(() => {
console.log('Graphic data:', STD.graphic);
// console.log('Tables:', changes, STD.graphic.tables);
// console.log('Cells:', STD.graphic.tables[0].cells());
client.end();
});
});