-
-
Notifications
You must be signed in to change notification settings - Fork 413
/
Copy pathFromToData.js
35 lines (28 loc) · 937 Bytes
/
FromToData.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
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();
});
});