indicator: "undefined" ...Recent update to Trading view api policy. #247
Unanswered
BlackPhoenixSlo
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Unanswered question: How can I run private indicators with API calls?
Answered: all work arounds.
[0] Error: Inexistent or unsupported indicator: "undefined"
Is what we all get.
There are 2 solutions.
Solution 1.

Cashe indicators.
Solution 2.
Use public indicators.
PUB;eb823f2928814c6f82d0713759d68892
insted of
USER;03d7ea932b9044e6aefc5d264f0e214f
Here is a code which can recreate all the bugs, it works now. I just removed TW sign, you will need to add google certifivate to export to google sheets.
`require('dotenv').config();
const { google } = require('googleapis');
const TradingView = require('@mathieuc/tradingview');
const {
appendAllDataFromJson
// import other utilities as needed
} = require('@blackphoenixslo/trading-bot-framework');
const indi_ = 'USER;03d7ea932b9044';
const id = "7pxbwffocii753w2z5jjdq0xf3jb0kri";
const certificate = "v3:BwppgofWBHNGegxr";
const timeframes = ['4H','1D','W'];
const markets = ['BTC','ETH','BNB'];
const spreadsheetId = "1LgcNfAvST9hdNAaf7KZXXHiCJvwilJHGsvUJBxkAoko";
async function getAuthToken() {
const SCOPES = ['https://www.googleapis.com/auth/spreadsheets'];
const auth = new google.auth.GoogleAuth({
scopes: SCOPES
});
const authToken = await auth.getClient();
return authToken;
}
async function fetchData(timeframe, ticket, indicator, client, timeframes) {
const chart = new client.Session.Chart();
console.log(Math.round((Date.now() - Date.UTC(2018, 1, 1)) / 1000 / 60 / 60 / 24 * (200 / timeframeMapping[timeframes[0]])));
chart.setMarket(ticket, {
timeframe: timeframe,
range: 20000,
to: Math.round((Date.now()) / 1000)
});
return new Promise((resolve, reject) => {
const study = new chart.Study(indicator);
study.onUpdate(() => {
resolve(study.periods);
});
});
}
const timeframeMapping = {
'5': 1, // Base timeframe
'15': 3, // 3 times the base timeframe
'30': 6, // 6 times the base timeframe
'1H': 12, // 12 times the base timeframe
'2H': 24, // 24 times the base timeframe
'3H': 36,
'4H': 48, // 48 times the base timeframe
'6H': 72, // 72 times the base timeframe
'8H': 96,
'12H': 144, // 144 times the base timeframe
'16H': 192,
'1D': 288, // 288 times the base timeframe
'2D': 576, // 576 times the base timeframe
'3D': 864, // 864 times the base timeframe
'4D': 1152, // 1152 times the base timeframe
'5D': 1440, // 1440 times the base timeframe
'6D': 1728, // 1728 times the base timeframe
'W': 2016, // 2016 times the base timeframe
'1M': 8640 // Adjust this number as per your requirement for a month
};
function processDataForTimeframes(timeframes, MoveDown = 0, ...dataArrays) {
const structuredData = [];
const initialPositions = {};
// Create initial arrays filled with zeros for each timeframe
timeframes.forEach(tf => {
initialPositions[tf] = new Array(MoveDown).fill(0);
});
// Process each timeframe
dataArrays[0].forEach((entry, index) => {
let row = {
'unix': entry.$time,
'time': new Date(entry.$time * 1000).toLocaleString(),
'closeprice': entry.ClosePrice,
'openprice': entry.OpenPrice
};
});
return structuredData;
}
async function start() {
const client = new TradingView.Client({ token: id, signature: certificate });
console.log(1);
// Fetch the indicator once
const indicator = await TradingView.getIndicator('PUB;eb823f2928814c6f82d0713759d68892').catch(error => { //indi_
console.log(2);
});
for (const coin of markets) {
const sheetTitle =
${coin}USDT
;const sheetTitle3 =
${coin}_reverse__USDT
;}
}
start();
`
Beta Was this translation helpful? Give feedback.
All reactions