# Interactive financial chart A VCL program that shows what `TAtlasFinChart` does on screen. The form is built in code (`CreateNew`), with a toolbar above a chart that fills the rest of the window. The chart has four panes on one shared time axis: | Pane | Weight | Studies | | --- | --- | --- | | Price | 300 | candles, Bollinger bands (20, 2), EMA(50) at line width 2 | | Volume | 90 | volume bars | | MACD | 110 | MACD(12, 26, 9): line, signal and histogram | | RSI | 90 | RSI(14) on its fixed 0..100 scale | It demonstrates: - **Crosshair.** `OnCrosshair` fills the toolbar label with the date, open, high, low, close and volume of the bar under the mouse, plus the RSI value read from the study's cached `Lines`. The pane headers show the same bar's values. - **Zoom and scroll.** The *Zoom in* and *Zoom out* buttons call `ZoomBy(0.8, ...)` and `ZoomBy(1.25, ...)` about the centre bar. *Show all* calls `ShowAll`. *Newest* calls `ScrollBy(MaxInt)`, which stops at the newest bar. The chart's own input works too: drag to scroll, turn the wheel to zoom about the cursor, double-click to show everything, drag the border between two panes to resize them, and use the keys listed below. - **View tracking.** `OnViewChange` writes the visible range into the form caption, for example `Atlas Fin: bars 141 to 260 of 260`. - **Price style.** The drop-down sets the first price study's `Kind` to candles, OHLC bars, a close line or a close area. - **Logarithmic scale.** The check box sets `Panes[0].Logarithmic`. The scale is rounded out to whole powers of ten. These prices (roughly 250 to 300) therefore sit in a narrow band of a 100 to 1000 scale. That is how the product behaves today, not a fault of the sample. - **Live bars.** *Live bars* starts a timer that moves the newest bar with `UpdateLast` and adds a new bar on every eighth tick. The chart starts on the newest 120 bars; a view that shows the newest bar follows new bars. Scroll back and the view stays where you left it. Following does not raise `OnViewChange`, so the timer updates the caption itself. Keyboard, once the chart has focus (it takes focus when clicked): Left and Right scroll one bar, Ctrl+Left and Ctrl+Right scroll a page, Home and End go to the oldest and newest bars, Up or numeric-keypad `+` zooms in, and Down or numeric-keypad `-` zooms out. ## Build and run Open `InteractiveFinChart.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. ## Expected result A 1100 × 720 window opens. It shows 120 candles from March to August 2026 with Bollinger bands and a thicker EMA line, and green and red volume bars below them. Under the volume are the MACD pane and the RSI pane. The price pane header ends with the date of the newest visible bar (28 August 2026). Moving the mouse draws a dashed vertical line through every pane and a horizontal line with a value tag at the right-hand axis. Over the newest bar the toolbar label reads `28/08/2026 O 271.65 H 277.80 L 269.81 C 275.74 Vol 1011433 RSI 57.3`; the date follows your Windows short date format. The data comes from a fixed `RandSeed`, so these numbers are the same on every run. ## Adapting it - Replace `FillBars` with `FChart.Data.LoadCSV(...)` or your own `Data.Add` calls. Wrap bulk loads in `BeginUpdate` / `EndUpdate` so the chart repaints once. - For real live data, call `UpdateLast` while a bar is forming and `Add` when the next one opens, on the main thread (for example from `TThread.Queue`). The series is not thread-safe. - Do not assign `FChart.Data.OnChange`: the chart uses that event itself to repaint and to follow new bars.