Open awb99 opened 1 year ago
time for daily, weekly, and monthly bars is expected to be a trading day (not session start day) at 00:00 UTC.
Enabling the extending time scale feature To enable the feature for a custom study:
Enable the 'studies_extend_time_scale' featureset. Add canExtendTimeScale: true to the study's metainfo.
custom_indicators_getter: function(PineJS) { return Promise.resolve([ { name: 'Complex Filled Areas', metainfo: { _metainfoVersion: 51, id: 'ComplexFilledAreas@tv-basicstudies-1', description: 'Complex Filled Areas', shortDescription: 'Complex Filled Areas', is_price_study: false, isCustomIndicator: true, plots: [ { id: 'plot_0', type: 'line', }, { id: 'plot_1', type: 'line', }, { id: 'plot_2', type: 'colorer', target: 'filledAreaId1', palette: 'paletteId1', }, ],
filledAreas: [
{
id: 'filledAreaId1',
objAId: 'plot_0',
objBId: 'plot_1',
title: 'Filled area between first and second plot',
type: 'plot_plot',
palette: 'paletteId1',
},
],
palettes: {
paletteId1: {
valToIndex: {
0: 0,
1: 1,
},
colors: {
0: {
name: 'First color',
},
1: {
name: 'Second color',
},
},
},
},
defaults: {
filledAreasStyle: {
filledAreaId1: {
color: 'yellow',
visible: true,
transparency: 40,
},
},
palettes: {
paletteId1: {
colors: {
0: {
color: 'red',
width: 1,
style: 0,
},
1: {
color: 'blue',
width: 3,
style: 1,
},
},
},
},
styles:
{
plot_0: {
linestyle: 0,
visible: true,
linewidth: 1,
plottype: 2,
trackPrice: true,
color: 'blue'
},
plot_1: {
linestyle: 1,
visible: true,
linewidth: 2,
plottype: 2,
trackPrice: true,
color: 'red'
},
},
precision: 4,
inputs: {}
},
styles:
{
plot_0:
{
title: 'First plot',
histogramBase: 0,
},
plot_1:
{
title: 'Second plot',
histogramBase: 0,
},
},
inputs: [],
format: {
type: 'price',
precision: 4,
},
},
constructor: function() {
this.main = function(context, inputCallback) {
this._context = context;
this._input = inputCallback;
var value = Math.random() * 200 - 100;
var colorIndex = value > 0 ? 0 : 1;
return [0, value, colorIndex];
}
}
}
]);
},
I think the real answer to this would be a BRIN index (https://en.wikipedia.org/wiki/Block_Range_Index), which I don't believe is in there, but would be rad to add.
Assuming you're sorted by timestamp... This implementation of binary search does exist:
Perhaps that's good enough for what you're up to? For sure it could be used to trounce going linear over the rows for each lookup.
Use the subscribe method to handle events raised when users interact with marks. You can also refresh and clear marks using the chart methods.
If you want to display two characters (like 'ED', 'AB', 'CD', etc.), you should enable the two_character_bar_marks_labels featureset.
One bar can have several marks. When a user clicks on the mark, the tooltip appears. The tooltip can only contain plain text. HTML code is not supported.
You can specify a timescale mark shape using the shape property. Images can be displayed within timescale marks by providing an image url in the imageUrl property. TimeScaleMarkShape Type "circle" | "earningUp" | "earningDown" | "earning"
Subscribe to library events.
Signature
subscribe
Signature
unsubscribe
TimeScaleMarkShape Type "circle" | "earningUp" | "earningDown" | "earning"