Creating shape or marks in custom indicator, (tradingview charting library (pinejs))

Viewed 2114
1 Answers

Yes you can. Here is the guide. For the callouts/Markers on chart you can follow this guide in the JS API. https://github.com/tradingview/charting_library/wiki/JS-Api#gettimescalemarkssymbolinfo-from-to-ondatacallback-resolution

For getmarks you can do this

 getMarks: (symbolInfo, startDate, endDate, onDataCallback, resolution) => {
    var Arr = [   
      {
        id: 1,
        time: 1551448800000 / 1000,
        color: 'blue',
        text: 'Hello world',
        label: 'B',
        labelFontColor: 'yellow',
        minSize: 20        
      },      
  ]
  onDataCallback(Arr);
    
    console.log("=====getMarks running");
  },

It will plot the marks above the bars as shown in the below image.

enter image description here

For Timescalemarks.

  getTimescaleMarks: (symbolInfo,startDate,endDate,onDataCallback,resolution) => {
onDataCallback([   
          {
            id: 1,
            time:  / 1000,
            color: 'Turquoise',
            label: 'The test you want to show on marker',
            minSize: 20,
            tooltip:[
              "Information you want to print",
            ]
          },
        ]);
})

The Time scale marks will look like this. And they will be plotted below the bars.

enter image description here

And for the shapes like circles and arrows you can follow this documentation. And use the createMultipointShape(points, options) methos to plot your shapes.

https://github.com/tradingview/charting_library/wiki/Chart-Methods#createmultipointshapepoints-options

Related