LightweightChartsIOS
LightweightChartsIOS copied to clipboard
How do we create a candles/volumes chart?
I have successfully overlaid candles with an area chart, so it is probably possible to overlay candles with volume (bar) chart. Howe er, they are on the same pricing scale, both from the same 0 line for y axis. A proper candle/volume chart would have volumes at the bottom, and then candles on top with fixed area. They have independent y scales.
Would appreciate to know if it is possible and have a sample chart in the Example app.
Hi @johnqh may I please know did you figure it out? thanks
The solution is to apply different priceScaleId
for xxxSeriesOptions.
Below is my sample setting for the chart.
let options = CandlestickSeriesOptions(
priceScaleId: "1",
priceLineSource: .lastVisible,
priceLineColor: "rgba(0, 0, 0, 0.5)",
upColor: "#fff",
downColor: "rgba(0, 0, 0, 0.8)",
borderUpColor: "rgba(0, 0, 0, 0.8)",
borderDownColor: "rgba(0, 0, 0, 0.8)",
wickUpColor: "rgba(0, 0, 0, 0.8)",
wickDownColor: "rgba(0, 0, 0, 0.8)"
)
let series = chart.addCandlestickSeries(options: options)
series.setData(data: candlestickData)
...
let volumeSeriesOptions = HistogramSeriesOptions(
lastValueVisible: false,
priceScaleId: "2",
priceLineVisible: false,
priceFormat: .builtIn(BuiltInPriceFormat(type: .volume, precision: nil, minMove: nil)),
color: "#26a69a"
)
let volumeSeries = chart.addHistogramSeries(options: volumeSeriesOptions)
volumeSeries.priceScale().applyOptions(
options: PriceScaleOptions(
scaleMargins: PriceScaleMargins(
top: 0.85,
bottom: 0
)
)
)
@wenweih Are the lines in this chart MA lines? How did you achieve it?