StockCandlestickChart

StockCandlestickChart

Plotting your own data (CSV)

Template data. Out of the box this widget draws 250 deterministic synthetic bars from xframe::make_seeded_series(250) — a random walk starting at 100.0, daily bars from 2026-01-01 UTC. Same seed, same bars, every run; no network, no live market data. It is only a stand-in.

CSV format. One bar per line, date,open,high,low,close,volume. A header row is optional; when present, columns are matched by name in any order (date, timestamp, time, window_start, open, high, low, close, volume — anything else is ignored, so Massive aggregates exports load as-is). Dates are UTC: YYYY-MM-DD, YYYY/MM/DD, YYYY-MM-DD HH:MM:SS, or an epoch timestamp in seconds, milliseconds or nanoseconds. volume is optional (defaults to 0); without a date column, bars get sequential daily timestamps from 2026-01-01 UTC. Blank lines are skipped; malformed rows are skipped and counted.

date,open,high,low,close,volume
2026-11-02,150.00,151.20,149.40,150.60,1200000
2026-11-03,150.60,152.10,150.10,151.80,980000

Working example. load_csv() reads the file with xframe::load_ohlcv_csv and replaces the series — the view resets to show all bars. On failure it returns false and the old series stays in place. Add these lines after constructing the widget (see the working example above for the full program):

#include "StockCandlestickChart.h"
std::string err;
if (!widget.load_csv("aapl_30d.csv", err)) {
    std::fprintf(stderr, "cannot load CSV: %s\n", err.c_str());
}
widget.draw();

Clear / populate. widget.clear_series() empties the chart (same as set_series({})); load_csv() or set_series(series) populates it again. There is no add_point — bars are replaced wholesale. item_count() reports how many items are plotted.

Full format spec, limits, and the notes for indicator and drawing widgets: Plotting your own data (CSV).