I’m new to the TradingView library. I’m trying to add a new custom chart with dummy data to the TradingView advanced charting library, but I’m encountering a runtime error and I’m not sure how to debug it. And also currently I’m using dummy data, what should I want to switch from dummy data to actual api that provide the data?
Current result:
Current result
Current result
I’ve tried running the code below but it doesn’t work. I was expecting a line chart to appear below my price chart.
custom_indicators_getter: (): Promise<CustomIndicator[]> => {
return Promise.resolve<CustomIndicator[]>([
{
name: 'Holders Over Time',
metainfo: {
_metainfoVersion: 51,
id: 'HoldersOverTime@custom' as RawStudyMetaInfoId,
description: 'Holders Over Time',
shortDescription: 'Holders OT',
is_price_study: false,
isCustomIndicator: true,
format: {
type: 'volume',
// Precision is set to zero digits because count of holders is an integer
precision: 0,
},
plots: [{ id: 'plot_0', type: StudyPlotType.Line }],
defaults: {
styles: {
plot_0: {
linestyle: 0,
visible: true,
linewidth: 1,
plottype: 2 as StudyLinePlotPreferences['plottype'],
trackPrice: true,
color: '#008800', // Dark green for holders
},
},
inputs: {},
},
styles: {
plot_0: {
title: 'Number of Holders',
histogramBase: 0,
},
},
inputs: [],
},
constructor: function (this: LibraryPineStudy<IPineStudyResult>) {
this.init = function (context, inputCallback) {
this._context = context;
this._input = inputCallback;
this.holdersMap = [...holdersOverTimeResponse];
};
this.main = function (context, inputCallback) {
this._context = context;
this._input = inputCallback;
const time = this._context.symbol.time;
const value = this.holdersData[time] || NaN;
return [value];
};
},
},
]);
},
export const holdersOverTimeResponse = [
{ date: 1512086400000, holders: 1200 },
{ date: 1512172800000, holders: 1100 },
{ date: 1512259200000, holders: 1300 },
{ date: 1512345600000, holders: 1400 },
{ date: 1512432000000, holders: 1000 },
{ date: 1512518400000, holders: 1150 },
]
0xPokatow is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.