Im using tradingview charting library and providing own data with JS API. After getting data from a server, I run the following inside the "getBars"-function:
const data = fetch_data_from_an_api();
let bars = [];
data.Data.forEach(bar => {
if (bar.time >= from && bar.time < to) {
bars = [...bars, {
time: bar.time * 1000,
low: bar.low,
high: bar.high,
open: bar.open,
close: bar.close,
}];
}
});
onHistoryCallback(bars, {
noData: false,
});
Each element in the array can look like this:
time: 1459814400,
close: 424.53,
high: 425,
low: 419.61,
open: 420.01,
volumefrom: 7219.7,
volumeto: 3052754.53,
conversionType: "force_direct",
conversionSymbol: ""
This draws bars in the widget. But they are "candles", because there is "close, open, low, high". In my case, I have my own data (the data above is fetched from another example-api) which only contains the "close". So the bars don't make sense in my graph. I want to draw lines instead of having bars. I attach here how it looks like when there are bars:
And I attach here how it looks like when I have the same value for "close, open, low, high". As you can see it only prints some kind of dots, but they do not form a line. I also tried to only put the "close" in the array of bars, but then the graph becomes empty.