openalgo-charts 2.3.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,12 +4,12 @@
4
4
 
5
5
  **A from-scratch, dependency-free HTML5-canvas charting engine for OpenAlgo.**
6
6
 
7
- Professional interactive charts, 102 built-in indicators plus your own custom ones, 85 drawing tools, order flow, market replay, linked chart grids, on-chart trading, vector SVG export and an optional WebGL2 backend. Eight lazy-loaded tiers, zero runtime dependencies, 77.23 KB Brotli for the base engine, and a one-call widget tier that adds the toolbar, drawing rail, dialogs and shortcuts.
7
+ Professional interactive charts, 102 built-in indicators plus your own custom ones, 85 drawing tools, order flow, market replay, linked chart grids, on-chart trading, vector SVG export and an optional WebGL2 backend. Eight lazy-loaded tiers, zero runtime dependencies, 78.07 KB Brotli for the base engine, and a one-call widget tier that adds the toolbar, drawing rail, dialogs and shortcuts.
8
8
 
9
9
  [![npm version](https://img.shields.io/npm/v/openalgo-charts.svg?color=cb3837&label=npm)](https://www.npmjs.com/package/openalgo-charts)
10
10
  [![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
11
- [![bundle](https://img.shields.io/badge/brotli-77.23%20KB%20base%20%C2%B7%20215.76%20KB%20all%20tiers-brightgreen.svg)](#size-budget)
12
- [![tests](https://img.shields.io/badge/tests-5182%20passing-brightgreen.svg)](#develop)
11
+ [![bundle](https://img.shields.io/badge/brotli-78.07%20KB%20base%20%C2%B7%20217.54%20KB%20all%20tiers-brightgreen.svg)](#size-budget)
12
+ [![tests](https://img.shields.io/badge/tests-5251%20passing-brightgreen.svg)](#develop)
13
13
  [![dependencies](https://img.shields.io/badge/runtime%20deps-0-brightgreen.svg)](#principles)
14
14
 
15
15
  [**Documentation**](https://marketcalls.github.io/openalgo-charts/)  ·  [**Live examples**](https://marketcalls.github.io/openalgo-charts/examples)  ·  [**Getting started**](./docs/getting-started.md)  ·  [**Migrating to 2.0**](./docs/migrating-to-2.md)  ·  [**Architecture**](./ARCHITECTURE.md)
@@ -20,6 +20,16 @@ Professional interactive charts, 102 built-in indicators plus your own custom on
20
20
 
21
21
  ---
22
22
 
23
+ ## Walkthrough video
24
+
25
+ A tour of OpenAlgo Charts running inside OpenAlgo: chart types, the indicator library,
26
+ drawing tools, order placement from the chart, market replay, combined option premium
27
+ charts, and the historical data explorer.
28
+
29
+ <p align="center">
30
+ <a href="https://www.youtube.com/watch?v=7Q_Twd6mNQ8"><img src="https://img.youtube.com/vi/7Q_Twd6mNQ8/maxresdefault.jpg" alt="OpenAlgo Charts walkthrough video" width="920" /></a>
31
+ </p>
32
+
23
33
  ## Live OpenAlgo trading terminal
24
34
 
25
35
  Right-click the chart to place market / limit / stop orders, drag the order and TP/SL bracket lines to modify, and watch live P&amp;L on the position line - all on real OpenAlgo history + WebSocket tick data, with an analyzer (sandbox) mode so nothing goes live until you arm it.
@@ -43,13 +53,15 @@ Every chart in the [live gallery](https://marketcalls.github.io/openalgo-charts/
43
53
 
44
54
  ## Install
45
55
 
46
- Current version: **2.3.2**.
56
+ Current version: **2.4.0**.
47
57
 
48
- This release makes history repair follow the stream: one refresh a moment after
49
- each bar closes, an immediate one when the stream skips a bucket, each fetching
50
- only the tail; and a forming bar the builder opened mid-bucket takes its true
51
- open from history instead of its first tick. See the
52
- [2.3.2 changelog](./CHANGELOG.md#232).
58
+ This release closes the gaps five hundred ported studies hit: a fold from the
59
+ chart's own bars to a higher timeframe (`securitySeries`), plots displaced by a
60
+ number of bars, a candle's wick coloured apart from its body, markers pinned to
61
+ the pane edge, tooltips on drawn zones, per-bar alert messages, a bars provider
62
+ for other instruments, and a calculation that throws is reported on its study
63
+ instead of thrown into the render loop. Every addition is optional. See the
64
+ [2.4.0 changelog](./CHANGELOG.md#240).
53
65
 
54
66
  ```bash
55
67
  npm install openalgo-charts
@@ -78,7 +90,7 @@ in front of npm rather than being places you upload to. A chart is one HTML file
78
90
  ```html
79
91
  <div id="chart" style="width:100vw;height:100vh"></div>
80
92
  <script type="module">
81
- import { createChart } from 'https://unpkg.com/openalgo-charts@2.3.2/dist/openalgo-charts.mjs';
93
+ import { createChart } from 'https://unpkg.com/openalgo-charts@2.4.0/dist/openalgo-charts.mjs';
82
94
  const chart = createChart(document.getElementById('chart'), { timezone: 'Asia/Kolkata' });
83
95
  chart.addSeries('candlestick').setData(bars);
84
96
  </script>
@@ -118,16 +130,16 @@ Import only what you use. Each tier is a separate bundle that registers into the
118
130
 
119
131
  | Import | Contents | Brotli |
120
132
  |---|---|---|
121
- | `openalgo-charts` | Engine, 13 chart types, panes &amp; scales, primitives, registries, chart state, chart linking, bar cache, interval registry, trading overlay, SVG export, render backend port, OpenAlgo feeds | 77.23 KB |
122
- | `openalgo-charts/indicators` | 102 built-in indicators, the `registerIndicator` contract for your own, and the Tier-2 (external-data) contract | 28.19 KB |
133
+ | `openalgo-charts` | Engine, 13 chart types, panes &amp; scales, primitives, registries, chart state, chart linking, bar cache, interval registry, trading overlay, SVG export, render backend port, OpenAlgo feeds | 78.07 KB |
134
+ | `openalgo-charts/indicators` | 102 built-in indicators, the `registerIndicator` contract for your own, and the Tier-2 (external-data) contract | 29.05 KB |
123
135
  | `openalgo-charts/draw` | 85 drawing tools + a headless drawing controller, clipboard, settings schema, level palette, freehand geometry and SVG icons | 34.53 KB |
124
136
  | `openalgo-charts/transform` | Heikin Ashi, Renko, Range bars, Line Break, Point &amp; Figure, Kagi, and symbol arithmetic (`AAPL/MSFT`) | 4.44 KB |
125
137
  | `openalgo-charts/profile` | Volume Profile, Market Profile (TPO) with compact pixel letters, Footprint, order flow | 14.96 KB |
126
138
  | `openalgo-charts/trade` | Order / position / bracket tools + DOM ladder | 7.61 KB |
127
- | `openalgo-charts/webgl` | WebGL2 series backend: batched, analytically anti-aliased GPU rendering of the standard chart types behind `renderer: 'auto'`, with a session-long fallback to the 2D path | 6.38 KB |
128
- | `openalgo-charts/widget` | The chart with its chrome in one call: `createWidget` adds a top bar, the drawing rail, a status line, the settings and indicator dialogs, drawing properties, a right-click menu, a keymap with a `?` panel and optional layout persistence. The only tier that ships DOM | 42.41 KB |
139
+ | `openalgo-charts/webgl` | WebGL2 series backend: batched, analytically anti-aliased GPU rendering of the standard chart types behind `renderer: 'auto'`, with a session-long fallback to the 2D path | 6.39 KB |
140
+ | `openalgo-charts/widget` | The chart with its chrome in one call: `createWidget` adds a top bar, the drawing rail, a status line, the settings and indicator dialogs, drawing properties, a right-click menu, a keymap with a `?` panel and optional layout persistence. The only tier that ships DOM | 42.49 KB |
129
141
 
130
- Everything together is **215.76 KB Brotli**; a widget terminal (base + draw + indicators + widget, what one `createWidget` call loads) is 182.37 KB. Figures are measured from the 2.3.2 release build. The trade tier is listed as its delta over the base, so loading base + trade costs 84.84 KB.
142
+ Everything together is **217.54 KB Brotli**; a widget terminal (base + draw + indicators + widget, what one `createWidget` call loads) is 184.14 KB. Figures are measured from the 2.4.0 release build. The trade tier is listed as its delta over the base, so loading base + trade costs 85.68 KB.
131
143
 
132
144
  ## What's built
133
145
 
@@ -146,6 +158,8 @@ macd.setSettings({ 'macd:width': 2, 'macd:lineStyle': 'dashed' });
146
158
 
147
159
  102 built-ins across Trend, Momentum, Volatility and Volume, from the everyday (SMA, EMA, WMA, VWAP, Bollinger Bands, RSI, MACD, Stochastic, ADX/DMI, ATR) through Supertrend, HalfTrend, Ichimoku, Keltner, Donchian, Chandelier Exit and CPR with floor pivots to Connors RSI, Fisher Transform, Woodies CCI, Klinger, Vortex, WaveTrend Pro, Chop Zone and Williams Fractals, with a least-squares family (Least Squares Moving Average, Linear Regression Slope, Standard Error, Standard Error Bands) and a Smoothed Moving Average alongside them, joined in 1.8.3 by the T3 average, the Hull Suite (Hma / Ehma / Thma with a displaced band) and Consolidation and Breakout, which tracks inside-bar ranges and marks the bar that leaves one. Twenty-eight of them draw shaded bands, six emit named buy/sell markers, two recolour the price candles, and Seasonality draws a monthly return heatmap as a table over the chart. The full catalogue with ids and defaults is in the docs.
148
160
 
161
+ Since 2.4.0 a study can fold the chart's own bars up to a higher timeframe with `securitySeries` (as the bucket stood at each bar, or the last completed one, or with lookahead when reproducing a source that repaints), paint a plot displaced by a number of bars, colour a candle's wick and border apart from its body, pin a marker to the pane edge, put a tooltip on a drawn zone, compute an alert message from the bar that fired, and ask the host for another instrument's bars through `chart.setBarsProvider`. A calculation that throws once it is on the chart is reported on that study's data status rather than thrown into the render loop.
162
+
149
163
  Every built-in is measured against its standard definition bar by bar, at several parameter sets, and each one's warmup (the first bar it can honestly produce a value for) is part of that check rather than an afterthought. A study draws nothing until it has the history it needs.
150
164
 
151
165
  The chart owns the whole lifecycle: series, pane placement, reference levels, fixed ranges (RSI 0..100), recompute on data change, teardown. Every plot gets colour, opacity, thickness, and line style for free, generated from the descriptor. Write your own with `registerIndicator`, or use the **Tier-2 contract** for indicators whose data isn't derived from OHLCV (open interest, CVD, any external feed).
@@ -419,16 +433,16 @@ Enforced in CI by [`size-limit`](./.size-limit.json). Nothing is excluded, becau
419
433
 
420
434
  | Bundle | Limit | Actual |
421
435
  |---|---|---|
422
- | Base engine | 78 KB | 77.23 KB |
423
- | Base + trade | 86 KB | 84.84 KB |
424
- | Indicators tier | 30 KB | 28.19 KB |
436
+ | Base engine | 79 KB | 78.07 KB |
437
+ | Base + trade | 86 KB | 85.68 KB |
438
+ | Indicators tier | 30 KB | 29.05 KB |
425
439
  | Draw tier | 36 KB | 34.53 KB |
426
440
  | Transform tier | 6 KB | 4.44 KB |
427
441
  | Profile tier | 15 KB | 14.96 KB |
428
- | WebGL2 tier | 7 KB | 6.38 KB |
429
- | Widget tier | 43 KB | 42.41 KB |
430
- | Widget terminal (base + draw + indicators + widget) | 183 KB | 182.37 KB |
431
- | **Everything** | 218 KB | 215.76 KB |
442
+ | WebGL2 tier | 7 KB | 6.39 KB |
443
+ | Widget tier | 43 KB | 42.49 KB |
444
+ | Widget terminal (base + draw + indicators + widget) | 185 KB | 184.14 KB |
445
+ | **Everything** | 218 KB | 217.54 KB |
432
446
 
433
447
  ## Documentation
434
448
 
@@ -490,7 +504,7 @@ npm run verify # lint + typecheck + test + build + demo tests + dts + size +
490
504
 
491
505
  ## Status &amp; limitations
492
506
 
493
- Version **2.3.2**. All engine build phases are implemented. Upgrading a 1.9.x host: [Migrating to 2.0](./docs/migrating-to-2.md).
507
+ Version **2.4.0**. All engine build phases are implemented. Upgrading a 1.9.x host: [Migrating to 2.0](./docs/migrating-to-2.md).
494
508
 
495
509
  Known gaps, stated plainly:
496
510
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Library version string. Matches package.json (including locally prepared releases). */
2
- declare const VERSION = "2.3.2";
2
+ declare const VERSION = "2.4.0";
3
3
  /** Returns the current library version. */
4
4
  declare function version(): string;
5
5
 
@@ -441,6 +441,15 @@ interface Bar {
441
441
  * two. Neither is expressible with one colour for the whole series.
442
442
  */
443
443
  color?: string;
444
+ /**
445
+ * Wick colour for this bar alone, over `color`. A study that paints candles
446
+ * with a translucent body and a solid wick cannot say so with one colour,
447
+ * and without this a per-bar override always set the two together. Read by
448
+ * the candle renderers only; absent means the wick follows `color`.
449
+ */
450
+ wickColor?: string;
451
+ /** Border colour for this bar alone, on the same terms as `wickColor`. */
452
+ borderColor?: string;
444
453
  }
445
454
  /** A single value point (for line/area/baseline series). */
446
455
  interface LinePoint {
@@ -600,6 +609,14 @@ interface SeriesStyle {
600
609
  * so whoever builds those readings owns their formatting.
601
610
  */
602
611
  precision?: number;
612
+ /**
613
+ * Draw every point this many bars to the right of the bar it belongs to
614
+ * (negative: left). The data is untouched and keeps its own times; only the
615
+ * painted position moves, so the last `barOffset` points of a series land in
616
+ * the right margin, past the newest bar. Autoscale follows what is drawn in
617
+ * view. Default 0.
618
+ */
619
+ barOffset?: number;
603
620
  color?: string;
604
621
  lineWidth?: number;
605
622
  /** Line dash style for line/step/area/HLC series. Default 'solid'. */
@@ -824,8 +841,13 @@ declare function bestHit(hits: readonly (PrimitiveHit | null)[]): PrimitiveHit |
824
841
  * body sits clear of it: `labelUp`'s tail points up so its body hangs below the
825
842
  * anchor, `labelDown` is the mirror. Both require `text`.
826
843
  */
827
- type MarkerShape = 'arrowUp' | 'arrowDown' | 'circle' | 'square' | 'triangleUp' | 'triangleDown' | 'diamond' | 'flag' | 'text' | 'labelUp' | 'labelDown';
828
- type MarkerPosition = 'aboveBar' | 'belowBar' | 'inBar' | 'atPrice';
844
+ type MarkerShape = 'arrowUp' | 'arrowDown' | 'circle' | 'square' | 'triangleUp' | 'triangleDown' | 'diamond' | 'flag' | 'text' | 'labelUp' | 'labelDown' | 'cross' | 'xcross';
845
+ /**
846
+ * `paneTop` and `paneBottom` pin the glyph to the edge of the plot rather than
847
+ * to a price, so a squeeze dot or a session flag sits in a fixed row whatever
848
+ * the scale does. They need no bar under them and no `price`.
849
+ */
850
+ type MarkerPosition = 'aboveBar' | 'belowBar' | 'inBar' | 'atPrice' | 'paneTop' | 'paneBottom';
829
851
  type MarkerSize = 'tiny' | 'small' | 'medium' | 'big';
830
852
  interface SeriesMarker {
831
853
  time: number;
@@ -1554,7 +1576,13 @@ interface ChartTableOptions {
1554
1576
  /** Column width in media px. A per-column array sizes each one separately. */
1555
1577
  cellWidth: number | readonly number[];
1556
1578
  cellHeight: number;
1557
- fontSize: number;
1579
+ /**
1580
+ * Type size in media px, or `'auto'` to fit each cell: as large as its row
1581
+ * allows, shrunk until its text also fits its column. A stretched grid with
1582
+ * one long label would otherwise either clip that cell or be sized down as a
1583
+ * whole to suit it.
1584
+ */
1585
+ fontSize: number | 'auto';
1558
1586
  /** Grid line colour. Omit to draw no grid. */
1559
1587
  borderColor?: string;
1560
1588
  borderWidth: number;
@@ -1678,6 +1706,36 @@ type IndicatorInput = {
1678
1706
  default: IndicatorSource;
1679
1707
  group?: string;
1680
1708
  tooltip?: string;
1709
+ }
1710
+ /**
1711
+ * A timeframe code (`'5m'`, `'1d'`), for a study that folds the chart's bars
1712
+ * up to a coarser interval. A settings UI renders it as a select over the
1713
+ * registered intervals, so the value is always one the engine can bucket by;
1714
+ * a free text box would accept `'5min'` and leave the study computing on a
1715
+ * code it cannot resolve. An empty default means "the chart's own interval".
1716
+ */
1717
+ | {
1718
+ key: string;
1719
+ type: 'interval';
1720
+ label: string;
1721
+ default: string;
1722
+ group?: string;
1723
+ tooltip?: string;
1724
+ }
1725
+ /**
1726
+ * A wall-clock instant in the chart's zone, written `YYYY-MM-DD HH:MM` (the
1727
+ * time part optional), for an anchor a user picks by date: the start of an
1728
+ * anchored VWAP, an event to measure from. It is carried as that string, not
1729
+ * as UTC seconds, so a layout saved in one zone restores to the same wall
1730
+ * clock in another, and `zonedStringToUtcSeconds` turns it into a bar time.
1731
+ */
1732
+ | {
1733
+ key: string;
1734
+ type: 'time';
1735
+ label: string;
1736
+ default: string;
1737
+ group?: string;
1738
+ tooltip?: string;
1681
1739
  };
1682
1740
  /** Dash pattern for a level, a drawing, or a plot. */
1683
1741
  type IndicatorLineStyle = 'solid' | 'dashed' | 'dotted';
@@ -1734,7 +1792,26 @@ interface IndicatorFillSpec {
1734
1792
  colorDownKey?: string;
1735
1793
  /** 0..1. Defaults to 0.12. */
1736
1794
  opacity?: number;
1795
+ /**
1796
+ * Draw the band on the price pane even though the indicator owns a pane of
1797
+ * its own. The pair with `IndicatorPlot.overlay`: a study can already send
1798
+ * one plot to the candles, and a band between two such plots belongs beside
1799
+ * them rather than in the study pane the fill would otherwise land in.
1800
+ * Ignored for an `'onchart'` descriptor, which is on the price pane already.
1801
+ */
1802
+ overlay?: boolean;
1737
1803
  }
1804
+ /**
1805
+ * What `colorParts` answers: a candle plot's colour split three ways, which is
1806
+ * how a study paints a wick in full colour over a translucent body. `body` is
1807
+ * the bar's colour (and the only part a line, histogram or column reads); a
1808
+ * part left undefined falls back to `colorBy`, then to the plot's own colour.
1809
+ */
1810
+ type PlotBarColor = {
1811
+ body?: string;
1812
+ wick?: string;
1813
+ border?: string;
1814
+ };
1738
1815
  interface IndicatorPlot {
1739
1816
  /** Key into the `calc` result. */
1740
1817
  key: string;
@@ -1772,6 +1849,16 @@ interface IndicatorPlot {
1772
1849
  * Ignored for an `'onchart'` descriptor, which is already on the price pane.
1773
1850
  */
1774
1851
  overlay?: boolean;
1852
+ /**
1853
+ * Draw the column shifted this many bars to the right (negative: left). The
1854
+ * column itself stays one value per bar and `calc` returns exactly what it
1855
+ * always did; only where each value is painted moves. Positive is what a
1856
+ * displaced cloud or a projected channel wants: the last `offset` values land
1857
+ * in the right margin, past the newest candle, where no bar exists to hold
1858
+ * them. It shifts the drawn series only. A fill between two plots with the
1859
+ * same offset follows; the legend reads the value drawn under the cursor.
1860
+ */
1861
+ offset?: number;
1775
1862
  /**
1776
1863
  * Settings key holding this plot's color, so a settings change restyles the
1777
1864
  * series without a full rebuild.
@@ -1812,6 +1899,19 @@ interface IndicatorPlot {
1812
1899
  values: IndicatorValues;
1813
1900
  settings: IndicatorSettings;
1814
1901
  }): string | undefined;
1902
+ /**
1903
+ * Per-bar colour split three ways, for a candle plot whose wick or border
1904
+ * should not follow its body: a solid wick over a translucent body, a
1905
+ * border in the trend colour. Takes precedence over `colorBy` for the parts
1906
+ * it names; a part it leaves undefined falls back to `colorBy`, then to the
1907
+ * plot's own colour. A value plot (line, histogram, column) reads `body` only.
1908
+ */
1909
+ colorParts?(ctx: {
1910
+ value: number;
1911
+ index: number;
1912
+ values: IndicatorValues;
1913
+ settings: IndicatorSettings;
1914
+ }): PlotBarColor | undefined;
1815
1915
  }
1816
1916
  /** A horizontal reference level (RSI 70/30, Stochastic 80/20, a zero line). */
1817
1917
  interface IndicatorLevel {
@@ -1861,6 +1961,17 @@ type IndicatorDrawing = {
1861
1961
  /** Caption drawn on a plate at the centre of the box; `\n` splits lines. */
1862
1962
  text?: string;
1863
1963
  textColor?: string;
1964
+ /**
1965
+ * Detail shown on a plate while the pointer rests on the box, and gone
1966
+ * when it leaves; `\n` splits lines. A zone that carries its size, its
1967
+ * age and what formed it cannot print all of that on the box without
1968
+ * hiding the candles under it, so the caption names it and this explains
1969
+ * it. The box becomes hit-testable, and `id` (or the tooltip text) is
1970
+ * what `subscribeClick` reports for it.
1971
+ */
1972
+ tooltip?: string;
1973
+ /** Hit id, for `subscribeClick`. Defaults to the tooltip text. */
1974
+ id?: string;
1864
1975
  } | {
1865
1976
  kind: 'label';
1866
1977
  at: DrawAnchor;
@@ -1871,6 +1982,10 @@ type IndicatorDrawing = {
1871
1982
  textColor?: string;
1872
1983
  /** Which edge of the plate sits on the anchor. Defaults to 'center'. */
1873
1984
  align?: 'left' | 'center' | 'right';
1985
+ /** Hover detail, as on a box. */
1986
+ tooltip?: string;
1987
+ /** Hit id, for `subscribeClick`. Defaults to the tooltip text. */
1988
+ id?: string;
1874
1989
  } | {
1875
1990
  kind: 'polyline';
1876
1991
  points: readonly DrawAnchor[];
@@ -1952,10 +2067,48 @@ interface IndicatorAlertSpec {
1952
2067
  id: string;
1953
2068
  /** Short human label, e.g. `'MACD crossed up'`. */
1954
2069
  title: string;
1955
- /** Longer text for a notification; defaults to `title`. */
1956
- message?: string;
2070
+ /**
2071
+ * Longer text for a notification; defaults to `title`. A function is handed
2072
+ * the same context `when` judged, so the message can carry the bar's own
2073
+ * numbers: the price it crossed at, the histogram reading, a JSON body for a
2074
+ * webhook. It runs only for a bar `when` accepted.
2075
+ */
2076
+ message?: string | ((ctx: IndicatorAlertContext) => string);
1957
2077
  when(ctx: IndicatorAlertContext): boolean;
1958
2078
  }
2079
+ /**
2080
+ * Thrown by a `calc` (or any hook) to say its inputs cannot produce a study,
2081
+ * the way a script language's runtime error does: a period at or below zero, a
2082
+ * fast length above the slow one, a benchmark the provider cannot serve.
2083
+ *
2084
+ * Any error out of a recompute is caught by the runtime and published on the
2085
+ * instance's data status as `{ state: 'error' }`, so the chart keeps drawing
2086
+ * every other indicator and a host can show the reason beside this one. This
2087
+ * class exists so a descriptor can throw a **named** condition and a host can
2088
+ * tell a bad input, which the user can fix, from a bug, which they cannot.
2089
+ */
2090
+ declare class IndicatorInputError extends Error {
2091
+ constructor(message: string);
2092
+ }
2093
+ /**
2094
+ * Bars of another instrument or interval, supplied by the host on request.
2095
+ *
2096
+ * The engine is handed one symbol's bars and owns no transport, so a study
2097
+ * that compares against a benchmark, or a Tier-2 provider that needs a second
2098
+ * series, asks the host through this and the host answers from wherever it
2099
+ * keeps history. `from` and `to` are UTC seconds; `signal` is aborted when the
2100
+ * instance is removed or its settings change, so a provider can drop the
2101
+ * request rather than answer into the void.
2102
+ */
2103
+ interface IndicatorBarsRequest {
2104
+ symbol: string;
2105
+ exchange?: string;
2106
+ interval: string;
2107
+ from: number;
2108
+ to: number;
2109
+ signal?: AbortSignal;
2110
+ }
2111
+ type IndicatorBarsProvider = (request: IndicatorBarsRequest) => Promise<readonly Bar[]>;
1959
2112
  /** Payload of the `'indicator:alert'` event on the chart's own bus. */
1960
2113
  interface IndicatorAlertPayload {
1961
2114
  /** Descriptor id, e.g. `'macd'`. */
@@ -2017,6 +2170,13 @@ interface IndicatorAttachContext {
2017
2170
  timezone?(): string;
2018
2171
  /** Chart wall clock in UTC seconds, the same clock the countdown row uses. */
2019
2172
  now?(): number;
2173
+ /**
2174
+ * Ask the host for another instrument's (or interval's) bars. Always present
2175
+ * under `chart.addIndicator`; it rejects when the host has registered no
2176
+ * provider (`chart.setBarsProvider`), so a study can treat the rejection as
2177
+ * "unsupported here" and say so through `setDataStatus`.
2178
+ */
2179
+ requestBars?(request: IndicatorBarsRequest): Promise<readonly Bar[]>;
2020
2180
  /** The pane this instance drew into. Moves when panes are reordered. */
2021
2181
  paneIndex?(): number;
2022
2182
  /** Attach a primitive to this indicator's pane, and detach it again. */
@@ -2656,6 +2816,12 @@ interface IndicatorHost {
2656
2816
  setBarColors?(colors: readonly (string | null)[] | null, owner: string): void;
2657
2817
  /** Emit on the chart's event bus (indicator alerts, and `attach`'s own events). */
2658
2818
  emit?(event: string, payload: unknown): void;
2819
+ /**
2820
+ * Bars of another instrument or interval, from wherever the host keeps its
2821
+ * history. Optional: without it the attach context's `requestBars` rejects,
2822
+ * which a study reads as "not available on this chart".
2823
+ */
2824
+ requestBars?(request: IndicatorBarsRequest): Promise<readonly Bar[]>;
2659
2825
  /**
2660
2826
  * Tick size of the named pane's price scale, or undefined when none is set.
2661
2827
  * Optional so a host predating it still satisfies this interface.
@@ -3775,6 +3941,15 @@ interface ChartOptions {
3775
3941
  * Tune a single pane later via `chart.panes()[n].priceScale.setOptions(...)`.
3776
3942
  */
3777
3943
  priceScale?: Partial<PriceScaleOptions>;
3944
+ /**
3945
+ * Where an indicator gets another instrument's bars. The engine is handed
3946
+ * one symbol's history and owns no transport, so a study that compares
3947
+ * against a benchmark asks through this and the host answers from wherever
3948
+ * it keeps candles. Change it later with `setBarsProvider`. Without one an
3949
+ * indicator's `requestBars` rejects, and the study reports itself
3950
+ * unsupported rather than drawing something invented.
3951
+ */
3952
+ barsProvider?: IndicatorBarsProvider;
3778
3953
  /**
3779
3954
  * Custom time-axis and crosshair label formatter (receives UTC seconds). When
3780
3955
  * omitted, labels use IST (Indian market default). e.g. for UTC:
@@ -4144,6 +4319,7 @@ declare class Chart {
4144
4319
  private _primary;
4145
4320
  private readonly _indicators;
4146
4321
  private _dataContext;
4322
+ private _barsProvider;
4147
4323
  /** Guards indicator recompute against re-entry via its own `series.setData`. */
4148
4324
  private _recomputing;
4149
4325
  private _indicatorsDirty;
@@ -4362,6 +4538,14 @@ declare class Chart {
4362
4538
  getDataContext(): Readonly<ChartDataContext> | undefined;
4363
4539
  /** Clear the previous source bars before changing context, then load the new source. */
4364
4540
  setDataContext(context: ChartDataContext | undefined): void;
4541
+ /**
4542
+ * Register, replace or remove (`null`) the provider indicators reach through
4543
+ * `requestBars`. Read at request time, so an indicator added before the
4544
+ * provider was set is served once one exists.
4545
+ */
4546
+ setBarsProvider(provider: IndicatorBarsProvider | null): void;
4547
+ /** Whether a bars provider is registered, so a host can grey what needs one. */
4548
+ hasBarsProvider(): boolean;
4365
4549
  /** Replace chart-owned branding. Manually attached primitives are independent. */
4366
4550
  setBranding(options: boolean | LogoWatermarkOptions): void;
4367
4551
  /** Host branding options, excluded from saved chart state. */
@@ -6539,6 +6723,13 @@ declare class IndicatorDrawings implements IPrimitive {
6539
6723
  private _items;
6540
6724
  private _host;
6541
6725
  private _visible;
6726
+ /**
6727
+ * The labels and boxes that carry an id or a tooltip, where the last frame
6728
+ * put them. Only those are hit-testable: a bare trendline stays under the
6729
+ * pointer as pure ink, so hovering a busy study does not light up a cursor
6730
+ * on every ray it drew.
6731
+ */
6732
+ private _hits;
6542
6733
  attached(host: PrimitiveHost): void;
6543
6734
  detached(): void;
6544
6735
  /** Over the series, under the crosshair: these are annotations on the data. */
@@ -6552,6 +6743,16 @@ declare class IndicatorDrawings implements IPrimitive {
6552
6743
  setItems(items: readonly IndicatorDrawing[]): void;
6553
6744
  setVisible(on: boolean): void;
6554
6745
  draw(ctx: CanvasRenderingContext2D, rc: PrimitiveRenderContext): void;
6746
+ /** Keep a label's or box's rect when it has something to say on hover or click. */
6747
+ private _recordHit;
6748
+ /**
6749
+ * The hovered shape's tooltip, as a plate clear of the shape: above it when
6750
+ * there is room, below it otherwise. Drawn last so it sits over everything
6751
+ * else in the layer, and only while the chart reports the pointer on it, so
6752
+ * it costs nothing on a frame with nothing hovered.
6753
+ */
6754
+ private _drawTooltip;
6755
+ hitTest(x: number, y: number): PrimitiveHit | null;
6555
6756
  }
6556
6757
 
6557
6758
  /**
@@ -8756,4 +8957,4 @@ declare function lerp(a: number, b: number, t: number): number;
8756
8957
  */
8757
8958
  declare function roundToTick(value: number, step: number): number;
8758
8959
 
8759
- export { ALT_PRESET, type AddSeriesOptions, type AggTick, type AxisChromeOptions, type AxisStyle, BAR_CACHE_VERSION, BUILTIN_COMMANDS, type Bar, BarCache, type BarCacheOptions, type BarCacheStats, type BarCacheStore, type BarSubscriptionOptions, type BarUpdate, type BarsPage, type BarsPageRequest, type BarsRequest, type BrandingChangedEvent, type Bucketing, BuySellButtons, type BuySellButtonsOptions, CHART_STATE_VERSION, type CachedBars, type CachedBarsRequest, type CalendarBucketing, type CalendarUnit, CandleBuilder, type CandleBuilderOptions, type CandleGeometry, type CandleStyle, type CandleTier, type CandleUpdate, Canvas2dBackend, type CanvasLineStyle, type CanvasOptions, Chart, type ChartClickEvent, type ChartDataContext, type ChartDragEndEvent, type ChartDragEvent, type ChartEvent, type ChartEventOptions, type ChartNavigationOptions, type ChartObjectCapabilities, type ChartObjectDefinition, type ChartObjectDrawing, type ChartObjectDrawingSource, type ChartObjectKind, type ChartObjectProvider, type ChartObjectSnapshot, ChartObjects, type ChartObjectsOptions, type ChartOptions, type ChartSettingsColorPairInput, type ChartSettingsInput, type ChartSettingsState, type ChartSettingsTab, type ChartSettingsTabId, type ChartSettingsValue, type ChartSettingsValues, type ChartState, ChartTable, type ChartTableOptions, type ChartTheme, type ChartWatermarkOptions, type ComparisonAlignment, type ComparisonChartHost, ComparisonController, type ComparisonControllerOptions, type ComparisonHandle, type ComparisonMode, type ComparisonOptions, type ComparisonPane, type ContextMenuEvent, type ContextMenuTarget, type ContextMenuTargetKind, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairStyle, type CustomShortcut, DEFAULT_CANDLE_BUILDER_OPTIONS, DEFAULT_CANDLE_STYLE, DEFAULT_CHART_TABLE_OPTIONS, DEFAULT_HISTOGRAM_STYLE, DEFAULT_KEYMAP, DEFAULT_PRICE_SCALE_OPTIONS, DEFAULT_THEME, DEFAULT_TIMEZONE, DEFAULT_TIME_NAVIGATOR_OPTIONS, DEFAULT_TIME_SCALE_OPTIONS, DEFAULT_TRADING_COLORS, DEFAULT_ZOOM_GLIDE_OPTIONS, type DataFeed, DataLayer, DataLoadingController, type DataLoadingOptions, type DataLoadingSnapshot, type DataLoadingStatus, type DataUpdateReason, type DecodedOrder, type DepthLevel, type DoubleClickAction, type DoubleClickEvent, type DrawAnchor, type DrawItem, EventMarkers, type ExportSvgOptions, FakeDataFeed, type FeedScheduler, type FillGradient, type FillPoint, type GridAxisStyle, type GridOptions, type GridStyle, type HistogramStyle, type HistoryLoadingStatus, HistoryRequestPool, type HistoryRequestPoolOptions, INDICATOR_LINE_STYLES, INDICATOR_PLOT_STYLES, INDICATOR_SOURCES, type IPrimitive, type IRenderBackend, IST_OFFSET_SECONDS, type IndexedBar, type IndicatorAlertContext, type IndicatorAlertPayload, type IndicatorAlertSpec, type IndicatorApi, type IndicatorAttachContext, IndicatorBackground, type IndicatorCalcContext, type IndicatorDataChange, type IndicatorDataStatus, type IndicatorDescriptor, type IndicatorDrawing, IndicatorDrawings, IndicatorFill, type IndicatorFillOptions, type IndicatorFillSpec, type IndicatorHost, type IndicatorInput, type IndicatorLevel, type IndicatorLevelContext, type IndicatorLineStyle, type IndicatorPlot, type IndicatorSettings, type IndicatorSource, type IndicatorState, type IndicatorStore, type IndicatorValues, type IntervalBucketing, type IntervalDescriptor, type IntervalParts, InvalidationLevel, type IstParts, type KeymapEntry, LINK_CROSSHAIR_ALPHA, type LateTickPolicy, type LegendField, type LegendStatusData, type LegendStatusLineOptions, type LegendStatusSource, type LegendTitleMode, type LegendValue, type LinePoint, type LinkChart, LinkCrosshair, type LinkDataLayer, LinkGroup, type LinkMemberOptions, type LinkMissingPolicy, type LinkOptions, type LiveBarMeta, type LogicalRange, LogoWatermark, type LogoWatermarkOptions, type LtpEvent, type MarkerPosition, type MarkerShape, type MarkerSize, type MarketDepth, type MarketPhase, type MarketPhaseFn, type MaybePromise, type ModeCheck, type OpenAlgoConfig, OpenAlgoDataFeed, type OpenAlgoLiveConfig, OpenAlgoLiveDataFeed, type OpenAlgoTradeConfig, OpenAlgoTradeFeed, type OpenAlgoWsConfig, OpenAlgoWsFeed, type OrderBookSnapshot, type OrderDecodeCode, type OrderDecodeIssue, type OrderDecodeResult, type OrderSide$1 as OrderSide, type OrderType$1 as OrderType, type OrderUpdateEvent, type OriginalTime, PRICE_LEVEL_KINDS, PRICE_SCALE_MODES, Pane, type PaneInvalidation, PaneLegend, type PaneLegendAction, type PaneLegendOptions, type PaneState, type PickHost, type PickKind, type PlaceOrder, type PlotMarginOptions, type PointerInfo, type PointerKind, type PointerModifiers, type PointerSample, type PositionSide, type PriceAxisState, type PriceFormat, type PriceLevelInput, type PriceLevelKind, type PriceLevelQuote, type PriceLevelStyle, type PriceLevelValues, PriceLevels, type PriceLevelsOptions, PriceLine, type PriceLineOptions, type PriceRange, PriceScale, type PriceScaleId, type PriceScaleMode, type PriceScaleOptions, type PriceScaleState, type PrimitiveAnchor, type PrimitiveHit, type PrimitiveHost, type PrimitivePlacement, type PrimitiveRenderContext, type QuarantinedRow, type RawOrder, type RenderBackendFactory, type RenderBackendKind, type RenderDevice, type RendererChoice, type RendererEntry, type RendererFallbackEvent, type RendererFallbackReason, type ReplayChartHost, ReplayController, type ReplayOptions, type ReplayScheduler, ReplayShade, type ReplayShadeOptions, type ReplayState, type ReplayViewport, type ResolvedLinkOptions, type RestoreReport, SCALE_FONT_MAX, SCALE_FONT_MIN, type ScaleCanvasOptions, type SeriesApi, type SeriesDataItem, type SeriesId, type SeriesMarker, SeriesMarkers, type SeriesRenderContext, type SeriesState, type SeriesStyle, type SeriesType, type SessionSpec, type ShortcutListItem, ShortcutManager, type ShortcutManagerOptions, type ShortcutPreset, type ShortcutScope, type ShortcutTriggerEvent, type Size, type SocketFactory, type SocketLike, type SupertrendPoint, SvgContext, type SvgContextOptions, SvgLinearGradient, type TableCell, type TablePosition, TextWatermark, type TextWatermarkOptions, type Tick, TickBarAggregator, type TickBarOptions, type TickCountBucketing, type TickMarkType, type TickTimeframe, TimeNavigator, type TimeNavigatorAction, type TimeNavigatorOptions, TimeScale, type TimeScaleOp, type TimeScaleOptions, type TradeFeed, type TradeMarkerVariant, TradeMarkersPrimitive, type TradingColors, TradingController, type TradingHost, type TradingLineStyle, type TradingLineVariant, type TradingOrder, type TradingOrderSide, type TradingOrderType, type TradingPosition, type TradingSettings, type TradingSyncPayload, type TradingTrade, type UTCSeconds, UnknownIntervalError, type UnsubscribeFn, VERSION, type VolumeBucketing, type VolumeMode, type WatermarkPosition, type Whitespace, type WsClientWarning, type WsControlMessage, type WsMode, type WsState, type ZOrder, type ZonedParts, type ZonedPeriod, type ZoomAnchor, ZoomGlide, type ZoomGlideOptions, addComparison, alignToPrimary, applyChartSettings, atr, autoscaleRange, backendDegradation, backoffDelayMs, barCacheKey, barCloseSec, beginPick, bestHit, bitmapSize, bucketStartOf, calendarPeriodFlags, candleGeometry, candleTier, chartSettingsSchema, clamp, classifyAuthAck, compactVolume, comparisonController, computePriceLevels, conflateBars, conflateItems, conflationGroupSize, createChart, createLinkGroup, createRenderBackend, darkTheme, dashPattern, decodeOrder, drawLabel, drawShape, effectiveMarkerPx, ema, emaSeries, epochMsToUtcSeconds, eventToCombo, followerIndex, followerRange, formatCombo, formatIstCrosshairLabel, formatIstDate, formatIstTime, formatIstTimeSeconds, formatSubscribe, formatUnsubscribe, formatZonedCrosshairLabel, formatZonedDate, formatZonedTime, formatZonedTimeSeconds, fromGradient, generateBars, getChartType, getIndicator, hasIndicator, inSessionAt, indicatorDefaults, indicatorStyleInputs, intervalParts, intervalToSeconds, isDailyInterval, isIntradayInterval, isKnownInterval, isNewIstDay, isNewZonedDay, isNewZonedMonth, isNewZonedPeriod, isNewZonedQuarter, isNewZonedWeek, isNewZonedYear, isRebasing, isReservedCombo, isSecondsInterval, isTickInterval, isTimeBucketed, isValidCombo, isValidTimezone, isWhitespace, istStringToUtcSeconds, lastPriceLevelFromSeriesStyle, lerp, lightTheme, mapHistoryResponse, mapOrder, mapOrderStatus, mapPosition, markerSizePx, mergeBars, nextBucketStart, niceTicks, normalizeCombo, optimalBarWidth, parseCombo, parseMessage, parseSessionSpec, parseTopic, plotStyleKeys, precisionForStep, readChartSettings, readSequence, registerChartType, registerIndicator, registerInterval, registerRenderBackend, registeredChartTypes, registeredIndicators, registeredIntervals, registeredRenderBackends, resolveCrosshairStyle, resolveGridStyle, resolveInterval, resolvePlotMargins, resolveRenderBackend, resolveScaleStyle, roundToTick, rowTimeToUtcSeconds, rsi, rsiSeries, seriesStyleForLastPriceLevel, sessionFlags, sessionStartFlags, sessionStartIndices, sharedHistoryRequests, snapToDevicePixel, sourceValue, sourceValues, startOfZonedDay, startOfZonedMonth, startOfZonedWeek, supertrend, supertrendSeries, tableOrigin, toBar, trueRange, tryResolveInterval, unregisterInterval, unregisterRenderBackend, utcSecondsToIstDateString, utcSecondsToIstParts, utcSecondsToZonedDateString, utcSecondsToZonedParts, version, verticalGradient, watermarkRect, withAlpha, withBarCache, zoneOffsetSeconds, zonedDayIndex, zonedStringToUtcSeconds, zonedWallClockToUtcSeconds, zonedWeekIndex };
8960
+ export { ALT_PRESET, type AddSeriesOptions, type AggTick, type AxisChromeOptions, type AxisStyle, BAR_CACHE_VERSION, BUILTIN_COMMANDS, type Bar, BarCache, type BarCacheOptions, type BarCacheStats, type BarCacheStore, type BarSubscriptionOptions, type BarUpdate, type BarsPage, type BarsPageRequest, type BarsRequest, type BrandingChangedEvent, type Bucketing, BuySellButtons, type BuySellButtonsOptions, CHART_STATE_VERSION, type CachedBars, type CachedBarsRequest, type CalendarBucketing, type CalendarUnit, CandleBuilder, type CandleBuilderOptions, type CandleGeometry, type CandleStyle, type CandleTier, type CandleUpdate, Canvas2dBackend, type CanvasLineStyle, type CanvasOptions, Chart, type ChartClickEvent, type ChartDataContext, type ChartDragEndEvent, type ChartDragEvent, type ChartEvent, type ChartEventOptions, type ChartNavigationOptions, type ChartObjectCapabilities, type ChartObjectDefinition, type ChartObjectDrawing, type ChartObjectDrawingSource, type ChartObjectKind, type ChartObjectProvider, type ChartObjectSnapshot, ChartObjects, type ChartObjectsOptions, type ChartOptions, type ChartSettingsColorPairInput, type ChartSettingsInput, type ChartSettingsState, type ChartSettingsTab, type ChartSettingsTabId, type ChartSettingsValue, type ChartSettingsValues, type ChartState, ChartTable, type ChartTableOptions, type ChartTheme, type ChartWatermarkOptions, type ComparisonAlignment, type ComparisonChartHost, ComparisonController, type ComparisonControllerOptions, type ComparisonHandle, type ComparisonMode, type ComparisonOptions, type ComparisonPane, type ContextMenuEvent, type ContextMenuTarget, type ContextMenuTargetKind, type CrosshairMoveEvent, type CrosshairOptions, type CrosshairStyle, type CustomShortcut, DEFAULT_CANDLE_BUILDER_OPTIONS, DEFAULT_CANDLE_STYLE, DEFAULT_CHART_TABLE_OPTIONS, DEFAULT_HISTOGRAM_STYLE, DEFAULT_KEYMAP, DEFAULT_PRICE_SCALE_OPTIONS, DEFAULT_THEME, DEFAULT_TIMEZONE, DEFAULT_TIME_NAVIGATOR_OPTIONS, DEFAULT_TIME_SCALE_OPTIONS, DEFAULT_TRADING_COLORS, DEFAULT_ZOOM_GLIDE_OPTIONS, type DataFeed, DataLayer, DataLoadingController, type DataLoadingOptions, type DataLoadingSnapshot, type DataLoadingStatus, type DataUpdateReason, type DecodedOrder, type DepthLevel, type DoubleClickAction, type DoubleClickEvent, type DrawAnchor, type DrawItem, EventMarkers, type ExportSvgOptions, FakeDataFeed, type FeedScheduler, type FillGradient, type FillPoint, type GridAxisStyle, type GridOptions, type GridStyle, type HistogramStyle, type HistoryLoadingStatus, HistoryRequestPool, type HistoryRequestPoolOptions, INDICATOR_LINE_STYLES, INDICATOR_PLOT_STYLES, INDICATOR_SOURCES, type IPrimitive, type IRenderBackend, IST_OFFSET_SECONDS, type IndexedBar, type IndicatorAlertContext, type IndicatorAlertPayload, type IndicatorAlertSpec, type IndicatorApi, type IndicatorAttachContext, IndicatorBackground, type IndicatorBarsProvider, type IndicatorBarsRequest, type IndicatorCalcContext, type IndicatorDataChange, type IndicatorDataStatus, type IndicatorDescriptor, type IndicatorDrawing, IndicatorDrawings, IndicatorFill, type IndicatorFillOptions, type IndicatorFillSpec, type IndicatorHost, type IndicatorInput, IndicatorInputError, type IndicatorLevel, type IndicatorLevelContext, type IndicatorLineStyle, type IndicatorPlot, type IndicatorSettings, type IndicatorSource, type IndicatorState, type IndicatorStore, type IndicatorValues, type IntervalBucketing, type IntervalDescriptor, type IntervalParts, InvalidationLevel, type IstParts, type KeymapEntry, LINK_CROSSHAIR_ALPHA, type LateTickPolicy, type LegendField, type LegendStatusData, type LegendStatusLineOptions, type LegendStatusSource, type LegendTitleMode, type LegendValue, type LinePoint, type LinkChart, LinkCrosshair, type LinkDataLayer, LinkGroup, type LinkMemberOptions, type LinkMissingPolicy, type LinkOptions, type LiveBarMeta, type LogicalRange, LogoWatermark, type LogoWatermarkOptions, type LtpEvent, type MarkerPosition, type MarkerShape, type MarkerSize, type MarketDepth, type MarketPhase, type MarketPhaseFn, type MaybePromise, type ModeCheck, type OpenAlgoConfig, OpenAlgoDataFeed, type OpenAlgoLiveConfig, OpenAlgoLiveDataFeed, type OpenAlgoTradeConfig, OpenAlgoTradeFeed, type OpenAlgoWsConfig, OpenAlgoWsFeed, type OrderBookSnapshot, type OrderDecodeCode, type OrderDecodeIssue, type OrderDecodeResult, type OrderSide$1 as OrderSide, type OrderType$1 as OrderType, type OrderUpdateEvent, type OriginalTime, PRICE_LEVEL_KINDS, PRICE_SCALE_MODES, Pane, type PaneInvalidation, PaneLegend, type PaneLegendAction, type PaneLegendOptions, type PaneState, type PickHost, type PickKind, type PlaceOrder, type PlotBarColor, type PlotMarginOptions, type PointerInfo, type PointerKind, type PointerModifiers, type PointerSample, type PositionSide, type PriceAxisState, type PriceFormat, type PriceLevelInput, type PriceLevelKind, type PriceLevelQuote, type PriceLevelStyle, type PriceLevelValues, PriceLevels, type PriceLevelsOptions, PriceLine, type PriceLineOptions, type PriceRange, PriceScale, type PriceScaleId, type PriceScaleMode, type PriceScaleOptions, type PriceScaleState, type PrimitiveAnchor, type PrimitiveHit, type PrimitiveHost, type PrimitivePlacement, type PrimitiveRenderContext, type QuarantinedRow, type RawOrder, type RenderBackendFactory, type RenderBackendKind, type RenderDevice, type RendererChoice, type RendererEntry, type RendererFallbackEvent, type RendererFallbackReason, type ReplayChartHost, ReplayController, type ReplayOptions, type ReplayScheduler, ReplayShade, type ReplayShadeOptions, type ReplayState, type ReplayViewport, type ResolvedLinkOptions, type RestoreReport, SCALE_FONT_MAX, SCALE_FONT_MIN, type ScaleCanvasOptions, type SeriesApi, type SeriesDataItem, type SeriesId, type SeriesMarker, SeriesMarkers, type SeriesRenderContext, type SeriesState, type SeriesStyle, type SeriesType, type SessionSpec, type ShortcutListItem, ShortcutManager, type ShortcutManagerOptions, type ShortcutPreset, type ShortcutScope, type ShortcutTriggerEvent, type Size, type SocketFactory, type SocketLike, type SupertrendPoint, SvgContext, type SvgContextOptions, SvgLinearGradient, type TableCell, type TablePosition, TextWatermark, type TextWatermarkOptions, type Tick, TickBarAggregator, type TickBarOptions, type TickCountBucketing, type TickMarkType, type TickTimeframe, TimeNavigator, type TimeNavigatorAction, type TimeNavigatorOptions, TimeScale, type TimeScaleOp, type TimeScaleOptions, type TradeFeed, type TradeMarkerVariant, TradeMarkersPrimitive, type TradingColors, TradingController, type TradingHost, type TradingLineStyle, type TradingLineVariant, type TradingOrder, type TradingOrderSide, type TradingOrderType, type TradingPosition, type TradingSettings, type TradingSyncPayload, type TradingTrade, type UTCSeconds, UnknownIntervalError, type UnsubscribeFn, VERSION, type VolumeBucketing, type VolumeMode, type WatermarkPosition, type Whitespace, type WsClientWarning, type WsControlMessage, type WsMode, type WsState, type ZOrder, type ZonedParts, type ZonedPeriod, type ZoomAnchor, ZoomGlide, type ZoomGlideOptions, addComparison, alignToPrimary, applyChartSettings, atr, autoscaleRange, backendDegradation, backoffDelayMs, barCacheKey, barCloseSec, beginPick, bestHit, bitmapSize, bucketStartOf, calendarPeriodFlags, candleGeometry, candleTier, chartSettingsSchema, clamp, classifyAuthAck, compactVolume, comparisonController, computePriceLevels, conflateBars, conflateItems, conflationGroupSize, createChart, createLinkGroup, createRenderBackend, darkTheme, dashPattern, decodeOrder, drawLabel, drawShape, effectiveMarkerPx, ema, emaSeries, epochMsToUtcSeconds, eventToCombo, followerIndex, followerRange, formatCombo, formatIstCrosshairLabel, formatIstDate, formatIstTime, formatIstTimeSeconds, formatSubscribe, formatUnsubscribe, formatZonedCrosshairLabel, formatZonedDate, formatZonedTime, formatZonedTimeSeconds, fromGradient, generateBars, getChartType, getIndicator, hasIndicator, inSessionAt, indicatorDefaults, indicatorStyleInputs, intervalParts, intervalToSeconds, isDailyInterval, isIntradayInterval, isKnownInterval, isNewIstDay, isNewZonedDay, isNewZonedMonth, isNewZonedPeriod, isNewZonedQuarter, isNewZonedWeek, isNewZonedYear, isRebasing, isReservedCombo, isSecondsInterval, isTickInterval, isTimeBucketed, isValidCombo, isValidTimezone, isWhitespace, istStringToUtcSeconds, lastPriceLevelFromSeriesStyle, lerp, lightTheme, mapHistoryResponse, mapOrder, mapOrderStatus, mapPosition, markerSizePx, mergeBars, nextBucketStart, niceTicks, normalizeCombo, optimalBarWidth, parseCombo, parseMessage, parseSessionSpec, parseTopic, plotStyleKeys, precisionForStep, readChartSettings, readSequence, registerChartType, registerIndicator, registerInterval, registerRenderBackend, registeredChartTypes, registeredIndicators, registeredIntervals, registeredRenderBackends, resolveCrosshairStyle, resolveGridStyle, resolveInterval, resolvePlotMargins, resolveRenderBackend, resolveScaleStyle, roundToTick, rowTimeToUtcSeconds, rsi, rsiSeries, seriesStyleForLastPriceLevel, sessionFlags, sessionStartFlags, sessionStartIndices, sharedHistoryRequests, snapToDevicePixel, sourceValue, sourceValues, startOfZonedDay, startOfZonedMonth, startOfZonedWeek, supertrend, supertrendSeries, tableOrigin, toBar, trueRange, tryResolveInterval, unregisterInterval, unregisterRenderBackend, utcSecondsToIstDateString, utcSecondsToIstParts, utcSecondsToZonedDateString, utcSecondsToZonedParts, version, verticalGradient, watermarkRect, withAlpha, withBarCache, zoneOffsetSeconds, zonedDayIndex, zonedStringToUtcSeconds, zonedWallClockToUtcSeconds, zonedWeekIndex };
@@ -1,4 +1,4 @@
1
- import { IndicatorDescriptor, ChartDataContext, IndicatorSettings, Bar, IndicatorInput, IndicatorPlot, IndicatorLevel } from 'openalgo-charts';
1
+ import { IndicatorDescriptor, ChartDataContext, IndicatorSettings, Bar, IndicatorBarsRequest, IndicatorInput, IndicatorPlot, IndicatorValues, IndicatorStore, IndicatorCalcContext, IndicatorLevel } from 'openalgo-charts';
2
2
 
3
3
  declare const SMA: IndicatorDescriptor;
4
4
  declare const WMA: IndicatorDescriptor;
@@ -1106,6 +1106,12 @@ interface Tier2Context {
1106
1106
  /** UTC seconds of the first and last source bar (0 when there are none). */
1107
1107
  from: number;
1108
1108
  to: number;
1109
+ /**
1110
+ * The host's bar provider, when the runtime supplies one, so a `fetch` that
1111
+ * needs another instrument's candles asks the host rather than carrying its
1112
+ * own transport and credentials. Rejects when the host registered none.
1113
+ */
1114
+ requestBars?(request: IndicatorBarsRequest): Promise<readonly Bar[]>;
1109
1115
  }
1110
1116
  interface Tier2Descriptor {
1111
1117
  id: string;
@@ -1114,6 +1120,22 @@ interface Tier2Descriptor {
1114
1120
  placement: 'onchart' | 'pane';
1115
1121
  inputs: readonly IndicatorInput[];
1116
1122
  plots: readonly IndicatorPlot[];
1123
+ /**
1124
+ * External columns to align besides the plots, by key. A point may carry
1125
+ * more than what is drawn: a benchmark close that `calc` divides by, an
1126
+ * open-interest figure a ratio is built from. Anything not named here or in
1127
+ * `plots` is dropped at alignment.
1128
+ */
1129
+ series?: readonly string[];
1130
+ /**
1131
+ * Combine the aligned external columns with the chart's own bars. Without
1132
+ * it the aligned columns are the result, one per plot, exactly as before.
1133
+ * With it, `external` holds every plot and `series` key aligned onto the
1134
+ * bars (last-known-value, `null` before the first point), and the return is
1135
+ * what the plots draw: a relative strength, a beta, a spread. Pure in its
1136
+ * arguments, like any `calc`.
1137
+ */
1138
+ calc?(bars: readonly Bar[], external: IndicatorValues, settings: Readonly<IndicatorSettings>, store: IndicatorStore, ctx?: IndicatorCalcContext): IndicatorValues;
1117
1139
  /** A host/provider can explicitly decline data it cannot supply. */
1118
1140
  supports?(ctx: Tier2Context): boolean;
1119
1141
  /** Load the series for the current window. */
@@ -1150,6 +1172,61 @@ interface Tier2Descriptor {
1150
1172
  */
1151
1173
  declare function createTier2Indicator(d: Tier2Descriptor): IndicatorDescriptor;
1152
1174
 
1175
+ /**
1176
+ * A higher-timeframe view of the chart's own bars, one value per source bar.
1177
+ *
1178
+ * A study written for a script language asks for the daily high on a 5-minute
1179
+ * chart and gets a column the same length as the chart. The engine has no
1180
+ * such call, and every port that needed one folded the bars by hand, each a
1181
+ * little differently: some anchored an hourly bucket to midnight and some to
1182
+ * the session open, some read the bucket as it stood and some read its final
1183
+ * values. This is the one fold, with the three readings named:
1184
+ *
1185
+ * - `offset: 0` (the default) reads the bucket **as it stood at that bar**:
1186
+ * its open so far, high and low so far, the bar's own close, volume so far.
1187
+ * It is what the live bar sees and it never uses a later bar.
1188
+ * - `offset: k` reads the bucket that completed `k` buckets before, held
1189
+ * constant across the current one. The classic non-repainting reference,
1190
+ * `close[1]` on the higher timeframe.
1191
+ * - `lookahead: true` reads the current bucket's **final** values on every one
1192
+ * of its bars. It uses bars that had not happened yet, which is what the
1193
+ * source it is porting did; it is here so that can be reproduced, not
1194
+ * recommended.
1195
+ *
1196
+ * Buckets follow the chart's calendar: a day is a day in `timezone`, a week
1197
+ * starts on Monday there, and a sub-day interval is anchored to the epoch, or
1198
+ * to the session open when `session` is given, which is how an exchange cuts
1199
+ * its hourly bars.
1200
+ */
1201
+
1202
+ interface SecurityOptions {
1203
+ /** The calendar the buckets are cut in. Defaults to the shipped default zone. */
1204
+ timezone?: string;
1205
+ /** Read each bucket's final values on all of its bars. Default false. */
1206
+ lookahead?: boolean;
1207
+ /** Read the bucket completed this many buckets ago. Default 0, the current one. */
1208
+ offset?: number;
1209
+ /**
1210
+ * A session window, `'0915-1530'`, that anchors sub-day buckets to the
1211
+ * session open instead of the epoch. Without it a 30-minute bucket on a
1212
+ * 09:15 open runs 09:00 to 09:30; with it, 09:15 to 09:45.
1213
+ */
1214
+ session?: string;
1215
+ }
1216
+ interface SecuritySeries {
1217
+ open: (number | null)[];
1218
+ high: (number | null)[];
1219
+ low: (number | null)[];
1220
+ close: (number | null)[];
1221
+ /** Null on a bucket none of whose bars carried volume. */
1222
+ volume: (number | null)[];
1223
+ /** Time of the first source bar in the bucket being read, UTC seconds. */
1224
+ bucketStart: (number | null)[];
1225
+ /** True on the first source bar of each bucket. */
1226
+ isNew: boolean[];
1227
+ }
1228
+ declare function securitySeries(bars: readonly Bar[], interval: string, options?: SecurityOptions): SecuritySeries;
1229
+
1153
1230
  declare const INDICATORS_TIER: "indicators";
1154
1231
  /** Every built-in descriptor, in picker order. */
1155
1232
  declare const BUILTIN_INDICATORS: readonly IndicatorDescriptor[];
@@ -1160,4 +1237,4 @@ declare const BUILTIN_INDICATORS: readonly IndicatorDescriptor[];
1160
1237
  */
1161
1238
  declare function registerBuiltinIndicators(): void;
1162
1239
 
1163
- export { ADAPTIVE_INDICATORS, ADL, ADX, ALLIGATOR, ALMA, ALPHATREND, AROON, AROON_OSCILLATOR, ATR, AVERAGE_DAILY_RANGE, AVERAGE_INDICATORS, AWESOME_OSCILLATOR, BALANCE_OF_POWER, BB_TREND, BOLLINGER, BOLLINGER_BANDWIDTH, BOLLINGER_PERCENT_B, BUILTIN_INDICATORS, CCI, CHAIKIN_MONEY_FLOW, CHAIKIN_OSCILLATOR, CHAIKIN_VOLATILITY, CHANDELIER_EXIT, CHANDE_KROLL_STOP, CHANDE_MOMENTUM, CHOPPINESS_INDEX, CHOP_ZONE, CONNORS_RSI, CONSOLIDATION_BREAKOUT, COPPOCK_CURVE, CPR, DEMA, DONCHIAN, DPO, EASE_OF_MOVEMENT, ELDER_FORCE_INDEX, EMA, ENVELOPE, FISHER_TRANSFORM, FLOW_INDICATORS, HALFTREND, HISTORICAL_VOLATILITY, HMA, HULL_SUITE, ICHIMOKU, INDEX_INDICATORS, INDICATORS_TIER, KAMA, KELTNER_CHANNEL, KLINGER_OSCILLATOR, KNOW_SURE_THING, LINREG_SLOPE, LSMA, MACD, MASS_INDEX, MA_CHANNEL, MA_CROSS, MA_RIBBON, MCGINLEY_DYNAMIC, MEDIAN, MFI, MOMENTUM, NET_VOLUME, NVI, OBV, OSCILLATOR_INDICATORS, OVERLAY_INDICATORS, PARABOLIC_SAR, PPO, PVI, PVO, PVT, RANGE_ANALYSIS, RANGE_INDICATORS, RELATIVE_VIGOR_INDEX, RELATIVE_VOLATILITY_INDEX, ROC, RSI, RSI_DIVERGENCE, SEASONALITY, SEASONALITY_INDICATORS, SIGNAL_INDICATORS, SMA, SMI, SMI_ERGODIC_INDICATOR, SMI_ERGODIC_OSCILLATOR, SMMA, SPECIAL_K, STANDARD_DEVIATION, STANDARD_ERROR, STANDARD_ERROR_BANDS, STOCHASTIC, STOCHASTIC_RSI, STRENGTH_INDICATORS, STUDY_INDICATORS, SUPERTREND, T3, TEMA, TREND_STRENGTH_INDEX, TRIX, TSI, TWAP, type Tier2Context, type Tier2Descriptor, type Tier2Point, ULCER_INDEX, ULTIMATE_OSCILLATOR, VOLATILITY_INDICATORS, VOLATILITY_STOP, VOLUME, VORTEX, VWAP, VWMA, WAVETREND, WAVETREND_INDICATORS, WILLIAMS_FRACTALS, WILLIAMS_PERCENT_R, WILLIAMS_VIX_FIX, WMA, WOODIES_CCI, alma, barsSince, cci, change, connorsStreak, correlation, createTier2Indicator, cumulative, dev, highest, highestBars, linreg, lowest, lowestBars, nulls, percentRank, percentileNearestRank, pivotHigh, pivotLow, registerBuiltinIndicators, rma, roc, rollingSum, sma, smaSeededEma, stdev, stoch, swma, valueWhen, vwma, wma };
1240
+ export { ADAPTIVE_INDICATORS, ADL, ADX, ALLIGATOR, ALMA, ALPHATREND, AROON, AROON_OSCILLATOR, ATR, AVERAGE_DAILY_RANGE, AVERAGE_INDICATORS, AWESOME_OSCILLATOR, BALANCE_OF_POWER, BB_TREND, BOLLINGER, BOLLINGER_BANDWIDTH, BOLLINGER_PERCENT_B, BUILTIN_INDICATORS, CCI, CHAIKIN_MONEY_FLOW, CHAIKIN_OSCILLATOR, CHAIKIN_VOLATILITY, CHANDELIER_EXIT, CHANDE_KROLL_STOP, CHANDE_MOMENTUM, CHOPPINESS_INDEX, CHOP_ZONE, CONNORS_RSI, CONSOLIDATION_BREAKOUT, COPPOCK_CURVE, CPR, DEMA, DONCHIAN, DPO, EASE_OF_MOVEMENT, ELDER_FORCE_INDEX, EMA, ENVELOPE, FISHER_TRANSFORM, FLOW_INDICATORS, HALFTREND, HISTORICAL_VOLATILITY, HMA, HULL_SUITE, ICHIMOKU, INDEX_INDICATORS, INDICATORS_TIER, KAMA, KELTNER_CHANNEL, KLINGER_OSCILLATOR, KNOW_SURE_THING, LINREG_SLOPE, LSMA, MACD, MASS_INDEX, MA_CHANNEL, MA_CROSS, MA_RIBBON, MCGINLEY_DYNAMIC, MEDIAN, MFI, MOMENTUM, NET_VOLUME, NVI, OBV, OSCILLATOR_INDICATORS, OVERLAY_INDICATORS, PARABOLIC_SAR, PPO, PVI, PVO, PVT, RANGE_ANALYSIS, RANGE_INDICATORS, RELATIVE_VIGOR_INDEX, RELATIVE_VOLATILITY_INDEX, ROC, RSI, RSI_DIVERGENCE, SEASONALITY, SEASONALITY_INDICATORS, SIGNAL_INDICATORS, SMA, SMI, SMI_ERGODIC_INDICATOR, SMI_ERGODIC_OSCILLATOR, SMMA, SPECIAL_K, STANDARD_DEVIATION, STANDARD_ERROR, STANDARD_ERROR_BANDS, STOCHASTIC, STOCHASTIC_RSI, STRENGTH_INDICATORS, STUDY_INDICATORS, SUPERTREND, type SecurityOptions, type SecuritySeries, T3, TEMA, TREND_STRENGTH_INDEX, TRIX, TSI, TWAP, type Tier2Context, type Tier2Descriptor, type Tier2Point, ULCER_INDEX, ULTIMATE_OSCILLATOR, VOLATILITY_INDICATORS, VOLATILITY_STOP, VOLUME, VORTEX, VWAP, VWMA, WAVETREND, WAVETREND_INDICATORS, WILLIAMS_FRACTALS, WILLIAMS_PERCENT_R, WILLIAMS_VIX_FIX, WMA, WOODIES_CCI, alma, barsSince, cci, change, connorsStreak, correlation, createTier2Indicator, cumulative, dev, highest, highestBars, linreg, lowest, lowestBars, nulls, percentRank, percentileNearestRank, pivotHigh, pivotLow, registerBuiltinIndicators, rma, roc, rollingSum, securitySeries, sma, smaSeededEma, stdev, stoch, swma, valueWhen, vwma, wma };