Skip to content

Commit

Permalink
Merge pull request #256 from Mathieu2301/hotfix/update_volume_indicat…
Browse files Browse the repository at this point in the history
…or_versions

Hotfix/update volume indicator versions
  • Loading branch information
Mathieu2301 authored Sep 12, 2024
2 parents 2ba221d + 29409bf commit 2ebda31
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
10 changes: 8 additions & 2 deletions examples/BuiltInIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ const TradingView = require('../main');
* This example tests built-in indicators like volume-based indicators
*/

const volumeProfile = new TradingView.BuiltInIndicator('VbPFixed@tv-basicstudies-139!');
const volumeProfile = new TradingView.BuiltInIndicator('VbPFixed@tv-basicstudies-241!');

if (!process.argv[2] && !['VbPFixed@tv-basicstudies-139!', 'Volume@tv-basicstudies-144'].includes(volumeProfile.type)) {
const AUTHENTICATED_INDICATORS = [
'VbPFixed@tv-basicstudies-241',
'VbPFixed@tv-basicstudies-241!',
'Volume@tv-basicstudies-241',
];

if (!process.argv[2] && !AUTHENTICATED_INDICATORS.includes(volumeProfile.type)) {
throw Error('Please specify your \'sessionid\' cookie');
}

Expand Down
2 changes: 1 addition & 1 deletion examples/ReplayMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ async function addIndicator(name, pineId, options = {}) {
});
}

addIndicator('Volume', 'Volume@tv-basicstudies-144');
addIndicator('Volume', 'Volume@tv-basicstudies-241');
addIndicator('EMA_50', 'STD;EMA', { Length: 50 });
addIndicator('EMA_200', 'STD;EMA', { Length: 200 });
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mathieuc/tradingview",
"version": "3.4.5",
"version": "3.4.6",
"description": "Tradingview instant stocks API, indicator alerts, trading bot, and more !",
"main": "main.js",
"scripts": {
Expand Down
20 changes: 16 additions & 4 deletions src/classes/BuiltInIndicator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* @typedef {'Volume@tv-basicstudies-144'
* | 'VbPFixed@tv-basicstudies-139!'
* @typedef {'Volume@tv-basicstudies-241'
* | 'VbPFixed@tv-basicstudies-241'
* | 'VbPFixed@tv-basicstudies-241!'
* | 'VbPFixed@tv-volumebyprice-53!'
* | 'VbPSessions@tv-volumebyprice-53'
* | 'VbPSessionsRough@tv-volumebyprice-53!'
Expand All @@ -17,11 +18,22 @@
*/

const defaultValues = {
'Volume@tv-basicstudies-144': {
'Volume@tv-basicstudies-241': {
length: 20,
col_prev_close: false,
},
'VbPFixed@tv-basicstudies-139!': {
'VbPFixed@tv-basicstudies-241': {
rowsLayout: 'Number Of Rows',
rows: 24,
volume: 'Up/Down',
vaVolume: 70,
subscribeRealtime: false,
first_bar_time: NaN,
last_bar_time: Date.now(),
extendToRight: false,
mapRightBoundaryToBarStartTime: true,
},
'VbPFixed@tv-basicstudies-241!': {
rowsLayout: 'Number Of Rows',
rows: 24,
volume: 'Up/Down',
Expand Down
2 changes: 1 addition & 1 deletion tests/builtInIndicator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('BuiltInIndicator', () => {
});

it('gets volume profile', async () => {
const volumeProfile = new TradingView.BuiltInIndicator('VbPFixed@tv-basicstudies-139!');
const volumeProfile = new TradingView.BuiltInIndicator('VbPFixed@tv-basicstudies-241!');
volumeProfile.setOption('first_bar_time', Date.now() - 10 ** 8);

const VOL = new chart.Study(volumeProfile);
Expand Down

0 comments on commit 2ebda31

Please sign in to comment.