1

How to draw lines between any two highs or lows of the candlestick bars to make a slanted trend line that can extend to left or right or both directions?

Extending left or right by creating a custom series manually using y = mx + b formula seems plausible, but a direct straight-forward method would be more appropriate.

user3330840
  • 6,143
  • 7
  • 26
  • 39

2 Answers2

2

It's impossible right now. lightweight-charts doesn't support drawings at all (except workaround for drawing trend line with series with the only 2 points).

We aren't going to add drawing itself to the library, but we thought about extending the API to allow you draw on canvas directly. If you'd like to use drawings, I can suggest you take a look at charting_library.

timocov
  • 1,088
  • 6
  • 16
1

to draw diagonal trend line use addLineSeries: https://jsfiddle.net/pv62e9da/5/

lineSeries = chart.addLineSeries({
  lastValueVisible: false
});
var tldata = [];
tldata.push({
  time: data[3].time,
  value: data[3].close
});
tldata.push({
  time: data[50].time,
  value: data[50].close
});
lineSeries.setData(tldata);
Daniel Garmoshka
  • 5,849
  • 39
  • 40