From 41d7b1eb4954f077ec98e7f6c123c39dd00301f6 Mon Sep 17 00:00:00 2001 From: Mathieu Colmon Date: Thu, 12 Sep 2024 20:25:47 +0200 Subject: [PATCH 1/3] Use updated version of volume built-in indicators --- examples/BuiltInIndicator.js | 4 ++-- examples/ReplayMode.js | 2 +- src/classes/BuiltInIndicator.js | 8 ++++---- tests/builtInIndicator.test.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/BuiltInIndicator.js b/examples/BuiltInIndicator.js index bc63204..33c78db 100644 --- a/examples/BuiltInIndicator.js +++ b/examples/BuiltInIndicator.js @@ -4,9 +4,9 @@ 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)) { +if (!process.argv[2] && !['VbPFixed@tv-basicstudies-241!', 'Volume@tv-basicstudies-241'].includes(volumeProfile.type)) { throw Error('Please specify your \'sessionid\' cookie'); } diff --git a/examples/ReplayMode.js b/examples/ReplayMode.js index 1c28eae..a3f58ed 100644 --- a/examples/ReplayMode.js +++ b/examples/ReplayMode.js @@ -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 }); diff --git a/src/classes/BuiltInIndicator.js b/src/classes/BuiltInIndicator.js index 9a4ceab..ae8ae69 100644 --- a/src/classes/BuiltInIndicator.js +++ b/src/classes/BuiltInIndicator.js @@ -1,6 +1,6 @@ /** - * @typedef {'Volume@tv-basicstudies-144' - * | 'VbPFixed@tv-basicstudies-139!' + * @typedef {'Volume@tv-basicstudies-241' + * | 'VbPFixed@tv-basicstudies-241!' * | 'VbPFixed@tv-volumebyprice-53!' * | 'VbPSessions@tv-volumebyprice-53' * | 'VbPSessionsRough@tv-volumebyprice-53!' @@ -17,11 +17,11 @@ */ 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', diff --git a/tests/builtInIndicator.test.ts b/tests/builtInIndicator.test.ts index d55f53e..712c45c 100644 --- a/tests/builtInIndicator.test.ts +++ b/tests/builtInIndicator.test.ts @@ -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); From 4ad99eb27fbec12f26ed83b6d829759dfb2f904c Mon Sep 17 00:00:00 2001 From: Mathieu Colmon Date: Thu, 12 Sep 2024 20:26:16 +0200 Subject: [PATCH 2/3] Bump to 3.4.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7b25159..2715ceb 100644 --- a/package.json +++ b/package.json @@ -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": { From 29409bfda8594f75837e8dc3ec101f67a2311f1b Mon Sep 17 00:00:00 2001 From: Mathieu Colmon Date: Thu, 12 Sep 2024 21:07:46 +0200 Subject: [PATCH 3/3] Add a built-in indicator --- examples/BuiltInIndicator.js | 8 +++++++- src/classes/BuiltInIndicator.js | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/examples/BuiltInIndicator.js b/examples/BuiltInIndicator.js index 33c78db..5dab76e 100644 --- a/examples/BuiltInIndicator.js +++ b/examples/BuiltInIndicator.js @@ -6,7 +6,13 @@ const TradingView = require('../main'); const volumeProfile = new TradingView.BuiltInIndicator('VbPFixed@tv-basicstudies-241!'); -if (!process.argv[2] && !['VbPFixed@tv-basicstudies-241!', 'Volume@tv-basicstudies-241'].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'); } diff --git a/src/classes/BuiltInIndicator.js b/src/classes/BuiltInIndicator.js index ae8ae69..daad45f 100644 --- a/src/classes/BuiltInIndicator.js +++ b/src/classes/BuiltInIndicator.js @@ -1,5 +1,6 @@ /** * @typedef {'Volume@tv-basicstudies-241' + * | 'VbPFixed@tv-basicstudies-241' * | 'VbPFixed@tv-basicstudies-241!' * | 'VbPFixed@tv-volumebyprice-53!' * | 'VbPSessions@tv-volumebyprice-53' @@ -21,6 +22,17 @@ const defaultValues = { length: 20, col_prev_close: false, }, + '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,