Skip to content

Candles and bars

Use OHLC when the open, high, low and close within each interval matter. The series overview explains how to add, update, hide and remove a series; the input table covers every renderer.

Bar::new(time, open, high, low, close, volume) stores one interval at its UTC open time. High must be at least the open and close; low must be at most both. Volume must be finite and nonnegative; use zero if unavailable. For example, (100, 105, 98, 103, 800) has a body from 100 to 103, a wick from 98 to 105 and rising colour under the default open/close rule.

ChartType offers Candles, Bars, HollowCandles, VolumeCandles and HighLow. Bars draw an open tick on the left and a close tick on the right. Hollow candles are hollow when close is above open. Volume candles scale body width against the largest visible bar volume; zero volume gives a body as thin as the wick. High-low draws the interval’s range.

This scene uses the fixed history from your first chart. Its candles use close versus previous close for direction. Pan, zoom and inspect the bars; the input history stays the same.

Candles coloured by previous closeOpen full size

Inspect candle bodies and wicks across the synthetic one-minute history.

The interactive example needs JavaScript and WebAssembly. You can still use the chart setup alongside it.

series_candles.rs
use egui_charts::Chart;
pub fn candles() -> Chart {
use egui_charts::ChartType;
let mut chart = crate::first_chart::first_chart();
chart.set_chart_type(ChartType::Candles);
let mut params = chart.chart_type_params().clone();
params.styles.candles.wick_visible = true;
params.styles.candles.color_by_previous_close = true;
chart.set_chart_type_params(params);
chart
}

The compiled setup is in series.rs. ChartTypeStyles::candles holds CandlesStyle: body visibility, wick visibility and colouring by previous close. BarsStyle controls the open tick and thin bars. Apply these through Chart::set_chart_type_params.

Main-series colours, wick width and candle border width live in ChartConfig. BarColors can override a bar’s body, wick and border. Added OHLC series use SeriesOptions::up_color and down_color; they do not expose the main series’ candle/bar style switches. All five types can be added series.

For smoothed OHLC, continue to Heikin-Ashi.