# Candle chart export The Atlas Fin quick start, and the project the [tutorial](https://youseful.software/delphi/atlas-fin.html#tutorial) builds step by step. A console program that: 1. fills a `TAtlasBarSeries` with 120 weekday bars (a fixed pseudo-random walk, so every run gives the same prices); 2. lays out a chart with `SetupDefault` (price with candles and SMA(20), volume, RSI(14)), then adds Bollinger bands to the price pane and a MACD pane; 3. checks that the SMA(20) study line equals the mean of the first twenty closes, that the Bollinger bands from `TAtlasIndicators` enclose the same average, and that RSI(14) starts at bar 15 and stays within 0..100; 4. writes the bars to CSV and reads them back; 5. saves `candles.png`, zooms to the last 40 bars, saves `candles-zoom.png` and `candles.svg`, and checks that the files exist and that the SVG text names the studies. The chart is never shown and has no parent: `SaveToFile` and `ToSVG` draw into a bitmap or an SVG document, so a console program or a service can produce chart images. Every step checks its own result. The program exits with code 0 when all checks pass, or prints the failed check and exits with code 1. It needs no input or network. ## Build and run Open `CandleChartExport.dpr` in Delphi 13; the IDE creates the project file. Add the Atlas Fin `src` folder and the Atlas Plot `src` folder to the project's search path, then build and run for Win32 or Win64. No packages need to be installed. The program needs no input. It checks its own results and stops with an error if any of them differs from the output below. ## Expected output ``` 120 bars from 2026-01-05 to 2026-06-19 ok: four panes: Price, Volume, Momentum, MACD ok: SMA(20) starts at bar 20 with the mean of the closes ok: Bollinger bands enclose the SMA ok: RSI(14) starts at bar 15 and stays within 0..100 last close 119.44, SMA(20) 117.61, RSI(14) 61.3 ok: CSV round trip ok: candles.png written ok: the view shows the last 40 bars ok: the SVG names the studies in the pane headers ok: candles.svg written Files written to C:\...\CandleChartExport ``` `candles-zoom.png` shows four panes. At the top is the price pane with 40 candles, the SMA(20) line and the three Bollinger lines; its header reads `Price O 118.06 H 119.86 L 117.77 C 119.44 SMA(20) 117.61 BB(20, 2) 117.61 120.21 115.01`. Below it are the volume bars, the RSI line on a fixed 0..100 scale, and the MACD line, signal line and histogram. Month names label the shared time axis. With no crosshair, the header values are those of the newest visible bar. The CSV check compares prices to within `1E-9`, not bit for bit. `ToCSV` writes numbers with `FloatToStr` (15 significant digits), so a computed price such as `119.4412...` can come back differing in its last bits. ## Adapting it - Load your own prices with `Chart.Data.LoadCSV(TFile.ReadAllText('prices.csv'))` in place of `FillBars`. The header must be exactly `time,open,high,low,close,volume`, even if the rows leave the volume out. - Change the layout: `Chart.Panes[0].Studies.Add(skEMA, 50)` adds a line to the price pane, and `Chart.Panes.Add('RSI', 80).Studies.Add(skRSI)` adds a pane of its own. - Pick another format by extension: `.bmp` and `.emf` work as well as `.png` and `.svg`. A width or height of 0 uses the control's own size, 640 × 420 by default.