Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do we create a candles/volumes chart? #53

Open
johnqh opened this issue Feb 21, 2023 · 3 comments
Open

How do we create a candles/volumes chart? #53

johnqh opened this issue Feb 21, 2023 · 3 comments

Comments

@johnqh
Copy link

johnqh commented Feb 21, 2023

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.

@wenweih
Copy link

wenweih commented Jun 19, 2023

Hi @johnqh may I please know did you figure it out? thanks

@wenweih
Copy link

wenweih commented Jun 19, 2023

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
        )
    )
)
image

@ildream
Copy link

ildream commented Jul 14, 2023

@wenweih Are the lines in this chart MA lines? How did you achieve it?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants