tradingview / lightweight-charts

Performant financial charts built with HTML5 canvas
https://www.tradingview.com/lightweight-charts/
Apache License 2.0
9.64k stars 1.65k forks source link

Interpolation for missing candle sticks #1288

Closed nuel77 closed 1 year ago

nuel77 commented 1 year ago

Is your feature request related to a problem? Please describe. Interpolation of candlestick data

To handle empty data for candlestick data, the graph skips that value if a data point is missing. for example, consider this graph

image

Here the data for day 23 is missing, And the graph skips that time point. Is there a way I can populate the missing data with the close price of the previous day so that the time range will be consistent without any missing values? Should look something like this.

image
SlicedSilver commented 1 year ago

If you want to leave blank spaces in the chart then you can use WhitespaceData. Which is essentially a data point with a time but no price values.

If you want to insert a bar which has all the ohlc values equal to the previous day's close then you would need to do this yourself in the data before using the setData method on the series.

Kusou1 commented 1 year ago

I would like to ask if Candlestick only supports the daily line level?

SlicedSilver commented 1 year ago

@Kusou1 Could you please clarify what you mean by 'daily line level'? I'm not sure what you are asking.

Kusou1 commented 1 year ago

i mean,timeframe only support 1d,not support 1m or 1h, or 15m @SlicedSilver

SlicedSilver commented 1 year ago

The library supports any timeframe that you would like to use. It will always plot a bar for every data point that you provide regardless of the timestamps of the data points.

I believe that you are actually asking about the formatting of the dates on the time scale. You can set timeVisible to true (https://tradingview.github.io/lightweight-charts/docs/api/interfaces/TimeScaleOptions#timevisible) within the time scale options.

chart.timeScale().applyOptions({
    timeVisible: true,
});
Kusou1 commented 1 year ago

but the time only expect yyyy-mm-dd,not yyy-mm-dd hh:mm:ss,how to solve

image
Kusou1 commented 1 year ago

@SlicedSilver image here how to set when i need use hh,mm,ss

SlicedSilver commented 1 year ago

The time property can accept a timestamp value (number) instead of a string of the date. You need to use a timestamp when the resolution is intraday (i.e. hours, minutes, ...).

https://tradingview.github.io/lightweight-charts/docs/time-zones https://tradingview.github.io/lightweight-charts/docs/api#time