market_chart library

Interactive trading charts for Flutter: candlesticks, line and area charts, volume, crosshair, zoom, scrolling and live updates, plus the maths for common indicators (moving averages, Bollinger Bands, RSI, MACD).

Classes

BollingerBands
Bollinger Bands, drawn over the prices: a moving average with a band deviations standard deviations above and below it.
BollingerBandsCalculator
Keeps Bollinger Bands up to date. See bollingerBands and IndicatorCalculator.
Candle
One price bar: the open, high, low and close prices for a period of time, plus the volume traded in it.
CandleAggregator
Keeps a list of candles up to date from a live feed.
EmaCalculator
Keeps an exponential moving average up to date. See ema and IndicatorCalculator.
Indicator
An indicator to draw on a MarketChart, listed in its indicators.
IndicatorCalculator
Works out an indicator for a list of values (for example closing prices) and keeps it up to date as the values change.
Macd
MACD in a panel below the prices: the MACD line, its signal line, and the difference between them as a histogram.
MacdCalculator
Keeps a MACD up to date. See macd and IndicatorCalculator.
MarketChart
An interactive trading chart.
MarketChartController
Controls a MarketChart from outside: jump back to the latest candle, zoom in and out, and find out whether the latest candle is in view.
MarketChartTheme
Colours and text size for a MarketChart.
MovingAverage
A moving average, drawn as a line over the prices.
Rsi
The Relative Strength Index (0 to 100), in a panel below the prices, with the overbought and oversold levels marked.
RsiCalculator
Keeps an RSI up to date. See rsi and IndicatorCalculator.
SmaCalculator
Keeps a simple moving average up to date. See sma and IndicatorCalculator.

Enums

MarketChartType
How prices are drawn.
MovingAverageType
Whether a MovingAverage is simple or exponential.
PriceSource
Which price of each candle an indicator uses.
TimeLabelKind
Where a time label is shown.

Extensions

CandlePrices on List<Candle>
Prices of a list of candles, for passing to indicators.

Functions

autoPrecision(double price) → int
Picks how many decimals to show for prices around price: 2 for prices of 1 or more, and enough to show about four significant digits below that (so 0.05123, not 0.05).
bollingerBands(List<double> values, {int period = 20, double deviations = 2}) → ({List<double?> lower, List<double?> middle, List<double?> upper})
Bollinger Bands: a simple moving average over period values (middle), with bands deviations standard deviations above (upper) and below (lower) it. The bands widen when prices swing more.
defaultTimeFormatter(DateTime time, Duration interval, TimeLabelKind kind) → String
The default time labels: 14:30 or Mar 5 on the axis, and Mar 5 14:30 or Mar 5, 2026 under the crosshair. Candles shorter than a minute also show seconds (14:30:05).
detectPricePrecision(List<Candle> candles) → int
Works out how many decimals to show for candles, as the chart does when pricePrecision isn't set: as many as the recent prices have (2.3405 has 4, 73720.01 has 2), and at least autoPrecision of the latest close. Prices that don't end within 8 decimals, such as calculated ones, get autoPrecision.
ema(List<double> values, int period) → List<double?>
Exponential moving average (EMA) over period values. It reacts faster than a simple average because recent values count for more.
formatCompact(double value) → String
Formats a large number briefly, for example 1.25K, 3.40M or 2.10B.
formatPrice(double value, int precision) → String
Formats a price with precision decimals and comma thousands separators, for example 64,250.50.
macd(List<double> values, {int fastPeriod = 12, int slowPeriod = 26, int signalPeriod = 9}) → ({List<double?> histogram, List<double?> macd, List<double?> signal})
Moving Average Convergence Divergence (MACD): how a fast and a slow moving average pull apart or come together.
rsi(List<double> values, {int period = 14}) → List<double?>
Relative Strength Index (RSI), from 0 to 100: how strong recent rises are compared with recent falls. Readings above 70 are often read as overbought, below 30 as oversold.
sma(List<double> values, int period) → List<double?>
Simple moving average (SMA): the average of the last period values.

Typedefs

MarketChartTimeFormatter = String Function(DateTime time, Duration interval, TimeLabelKind kind)
Turns a candle time into a label.