Skip to content

Candlestick example

This example demonstrates how to create a simple candlestick chart using the CandleStickSeries.

Data format: the series expects a sequence of candlestick data points (time, open, high, low, close, volume). Check docs/api/struct_q_trading_view_1_1_candle_stick.html for the exact struct layout generated by Doxygen.

Example (pseudo-real code):

#include <QApplication>
#include <QTradingView>

int main(int argc, char** argv) {
    QApplication app(argc, argv);

    // Prepare data (fill according to the project's CandleStick struct)
    std::vector<QTradingView::CandleStick> data;
    data.push_back({ /* timestamp */ 1630000000, /* open */ 100.0, /* high */ 110.0, /* low */ 95.0, /* close */ 105.0, /* volume */ 1234.0 });
    // ... append more points

    auto chart = new QTradingView::Chart();
    auto pane = chart->addPane(1.0);

    pane->addSeries(std::make_shared<QTradingView::CandleStickSeries>(data));
    chart->fitToData();
    chart->show();

    return app.exec();
}

Build and run: use CMake to build the examples directory or integrate this snippet into your own Qt application.