acttrader-charts 1.3.0-beta.2 → 1.3.0-beta.21
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 +405 -16
- package/dist/{MACD-D1i-sEFR.d.cts → MACD-B6SoR6iH.d.cts} +486 -18
- package/dist/{MACD-D1i-sEFR.d.ts → MACD-B6SoR6iH.d.ts} +486 -18
- package/dist/index.cjs +3792 -448
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +679 -18
- package/dist/index.d.ts +679 -18
- package/dist/index.js +3702 -374
- package/dist/index.js.map +1 -1
- package/dist/indicators/index.d.cts +2 -2
- package/dist/indicators/index.d.ts +2 -2
- package/dist/webview/chart.html +90 -82
- package/package.json +1 -1
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
declare class ScaleManager {
|
|
2
|
+
private static readonly VERTICAL_PADDING_PX;
|
|
3
|
+
xToPixel(index: number, viewport: Viewport, chartWidth: number): number;
|
|
4
|
+
pixelToBarIndex(x: number, viewport: Viewport, chartWidth: number): number;
|
|
5
|
+
candleBodyWidth(viewport: Viewport, chartWidth: number): number;
|
|
6
|
+
yToPixel(price: number, range: PriceRange, chartHeight: number): number;
|
|
7
|
+
pixelToPrice(y: number, range: PriceRange, chartHeight: number): number;
|
|
8
|
+
volumeToPixel(volume: number, maxVolume: number, volumePanelHeight: number): number;
|
|
9
|
+
}
|
|
10
|
+
|
|
1
11
|
/**
|
|
2
12
|
* Definition of a multi-chart layout preset (grid template).
|
|
3
13
|
* Used by the chart-owned LayoutPopover and emitted via the `layoutChange` event.
|
|
@@ -45,16 +55,6 @@ declare const PRESET_LABEL: Record<string, string>;
|
|
|
45
55
|
/** Default sync state — matches the host's current defaults in useChartLayout.ts. */
|
|
46
56
|
declare const DEFAULT_LAYOUT_SYNC: LayoutSyncState;
|
|
47
57
|
|
|
48
|
-
declare class ScaleManager {
|
|
49
|
-
private static readonly VERTICAL_PADDING_PX;
|
|
50
|
-
xToPixel(index: number, viewport: Viewport, chartWidth: number): number;
|
|
51
|
-
pixelToBarIndex(x: number, viewport: Viewport, chartWidth: number): number;
|
|
52
|
-
candleBodyWidth(viewport: Viewport, chartWidth: number): number;
|
|
53
|
-
yToPixel(price: number, range: PriceRange, chartHeight: number): number;
|
|
54
|
-
pixelToPrice(y: number, range: PriceRange, chartHeight: number): number;
|
|
55
|
-
volumeToPixel(volume: number, maxVolume: number, volumePanelHeight: number): number;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
58
|
interface DrawingToolbarUiConfig {
|
|
59
59
|
/** Icon button size (width = height) in px */
|
|
60
60
|
iconBtnSize: number;
|
|
@@ -89,6 +89,15 @@ interface DrawingToolbarUiConfig {
|
|
|
89
89
|
* Default: `false` (original icons, unchanged for all existing consumers).
|
|
90
90
|
*/
|
|
91
91
|
modernIcons?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Glyph on the toolbar's Actions button — the one that opens Undo / Redo /
|
|
94
|
+
* Delete / Clear / Hide / Lock All. `'lock'` uses the same lock as the Lock
|
|
95
|
+
* All action, so the button reads as the place where drawings get locked and
|
|
96
|
+
* saved (the Hanko reference; pair it with a `labels.drawingToolbar.actions.lockAll`
|
|
97
|
+
* override such as "Save Charts"). Default `'default'`: the classic ⋯, or the
|
|
98
|
+
* Lucide pointer when `modernIcons` is on — unchanged for existing consumers.
|
|
99
|
+
*/
|
|
100
|
+
actionsButtonIcon?: 'default' | 'lock';
|
|
92
101
|
}
|
|
93
102
|
interface TopBarUiConfig {
|
|
94
103
|
/** Height of the top bar strip */
|
|
@@ -243,6 +252,16 @@ interface TopBarLabels {
|
|
|
243
252
|
settingsTitle: string;
|
|
244
253
|
/** Tooltip on the TFC (Trade from Charts) toggle button. */
|
|
245
254
|
tfcToggleTitle: string;
|
|
255
|
+
/** Crosshair switch tooltip while the crosshair is on (`enableCrosshairToggle`). */
|
|
256
|
+
disableCrosshairTitle: string;
|
|
257
|
+
/** Crosshair switch tooltip while the crosshair is off. */
|
|
258
|
+
enableCrosshairTitle: string;
|
|
259
|
+
/** Header P/L pill switch label (`features.pnlPill`). */
|
|
260
|
+
pnlPillBtn: string;
|
|
261
|
+
/** P/L pill switch tooltip while the pill is shown. `{symbol}` is filled in. */
|
|
262
|
+
hidePnlPillTitle: string;
|
|
263
|
+
/** P/L pill switch tooltip while the pill is hidden. */
|
|
264
|
+
showPnlPillTitle: string;
|
|
246
265
|
}
|
|
247
266
|
interface BottomBarLabels {
|
|
248
267
|
/** Duration selector button labels. */
|
|
@@ -262,6 +281,7 @@ interface DrawingToolbarLabels {
|
|
|
262
281
|
elliott: string;
|
|
263
282
|
brushes: string;
|
|
264
283
|
advanced: string;
|
|
284
|
+
forecasting: string;
|
|
265
285
|
priceProjection: string;
|
|
266
286
|
};
|
|
267
287
|
/** Individual drawing tool names (used in flyout rows). */
|
|
@@ -315,6 +335,20 @@ interface TradeLabels {
|
|
|
315
335
|
qty: string;
|
|
316
336
|
/** Tooltip on the floating trade button (⊕). */
|
|
317
337
|
placeOrderTitle: string;
|
|
338
|
+
/** Trade action bar (`features.tradeActionBar`) chips — Alert · Pending · SL · TP · TSL — and its × tooltip. */
|
|
339
|
+
actionAlert: string;
|
|
340
|
+
actionPending: string;
|
|
341
|
+
actionSl: string;
|
|
342
|
+
actionTp: string;
|
|
343
|
+
actionTsl: string;
|
|
344
|
+
actionCloseTitle: string;
|
|
345
|
+
/** Pending sub-menu header: which side of the market the clicked price is on. */
|
|
346
|
+
directionAbove: string;
|
|
347
|
+
directionBelow: string;
|
|
348
|
+
/** SL / TP / TSL chips greyed out: no open positions on the symbol. `{symbol}` is filled in. */
|
|
349
|
+
actionBulkNoPositionsTitle: string;
|
|
350
|
+
/** SL / TP / TSL chips greyed out: buys and sells both open — one price cannot suit both. */
|
|
351
|
+
actionBulkMixedTitle: string;
|
|
318
352
|
}
|
|
319
353
|
interface DialogLabels {
|
|
320
354
|
/** Chart Settings dialog. */
|
|
@@ -362,6 +396,21 @@ interface ChartMiscLabels {
|
|
|
362
396
|
* are active. Use `{count}` as a placeholder for the count. */
|
|
363
397
|
nIndicators: string;
|
|
364
398
|
}
|
|
399
|
+
/** On-chart P/L pill (`features.pnlPill`). Titles may use `{symbol}` and `{count}`. */
|
|
400
|
+
interface PnlPillLabels {
|
|
401
|
+
/** Short word after the count — `3 POS`. Rendered uppercase. */
|
|
402
|
+
positionsAbbrev: string;
|
|
403
|
+
/** Pill tooltip while the positions are collapsed — a click on the body fans them out. */
|
|
404
|
+
showPositionsTitle: string;
|
|
405
|
+
/** Pill tooltip while the positions are fanned out. */
|
|
406
|
+
hidePositionsTitle: string;
|
|
407
|
+
/** ◎ tooltip — it opens the host's Bulk Levels dialog. `{count}` and `{symbol}` are filled in. */
|
|
408
|
+
bulkLevelsTitle: string;
|
|
409
|
+
/** ◎ tooltip while greyed out because buys and sells are both open. */
|
|
410
|
+
bulkLevelsMixedTitle: string;
|
|
411
|
+
/** Amber ✕ tooltip. */
|
|
412
|
+
closeAllTitle: string;
|
|
413
|
+
}
|
|
365
414
|
interface ChartLabels {
|
|
366
415
|
topBar: TopBarLabels;
|
|
367
416
|
bottomBar: BottomBarLabels;
|
|
@@ -370,6 +419,7 @@ interface ChartLabels {
|
|
|
370
419
|
trade: TradeLabels;
|
|
371
420
|
dialogs: DialogLabels;
|
|
372
421
|
chart: ChartMiscLabels;
|
|
422
|
+
pnlPill: PnlPillLabels;
|
|
373
423
|
}
|
|
374
424
|
declare const DEFAULT_LABELS: ChartLabels;
|
|
375
425
|
/**
|
|
@@ -581,7 +631,7 @@ interface PriceRange {
|
|
|
581
631
|
}
|
|
582
632
|
type SeriesType = "candlestick" | "hollow" | "line" | "area" | "ohlc" | "heikinashi" | "volumecandles" | "linemarkers" | "step" | "hlcarea" | "baseline" | "columns" | "highlow";
|
|
583
633
|
type Theme = "dark" | "light";
|
|
584
|
-
type Timeframe = "1m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "8h" | "1D" | "1W" | "1M";
|
|
634
|
+
type Timeframe = "1m" | "3m" | "4m" | "5m" | "10m" | "15m" | "30m" | "1h" | "2h" | "4h" | "8h" | "1D" | "1W" | "1M";
|
|
585
635
|
type Duration = "1D" | "5D" | "1M" | "3M" | "6M" | "1Y" | "5Y" | "All";
|
|
586
636
|
interface Padding {
|
|
587
637
|
top: number;
|
|
@@ -602,6 +652,15 @@ interface DataLoaderParams {
|
|
|
602
652
|
start: Date;
|
|
603
653
|
end: Date;
|
|
604
654
|
interval: string;
|
|
655
|
+
/**
|
|
656
|
+
* Which price the chart is currently building candles from
|
|
657
|
+
* (`tickClosePriceSource`: `'bid'`, `'ask'` or `'ltp'`). Forward it to your
|
|
658
|
+
* history API (e.g. as a query parameter) so the fetched bars match the
|
|
659
|
+
* source the user picked in the header dropdown — the engine re-runs the
|
|
660
|
+
* loader with the new value whenever the source changes. Always set by the
|
|
661
|
+
* engine; optional only so callers that build params by hand keep compiling.
|
|
662
|
+
*/
|
|
663
|
+
priceSource?: 'bid' | 'ask' | 'ltp';
|
|
605
664
|
}
|
|
606
665
|
/**
|
|
607
666
|
* Params passed to `compareDataLoader`. Mirrors `DataLoaderParams` but also
|
|
@@ -618,6 +677,67 @@ type ThemeOverrides = {
|
|
|
618
677
|
dark?: DeepPartialChartTheme;
|
|
619
678
|
light?: DeepPartialChartTheme;
|
|
620
679
|
};
|
|
680
|
+
/**
|
|
681
|
+
* What a price *means* for this instrument.
|
|
682
|
+
*
|
|
683
|
+
* The chart reads prices, never contract specs — so a tool that wants to report
|
|
684
|
+
* a distance in pips, or convert it to money, has to be told how. Every field is
|
|
685
|
+
* optional and every one degrades to a documented fallback, so an existing
|
|
686
|
+
* integration that omits the block keeps working and simply shows price-only
|
|
687
|
+
* readouts.
|
|
688
|
+
*
|
|
689
|
+
* Per-position values still travel on the individual `TradeLevel`; this block is
|
|
690
|
+
* the instrument-wide default for tools that aren't attached to a position.
|
|
691
|
+
*/
|
|
692
|
+
interface InstrumentSpec {
|
|
693
|
+
/**
|
|
694
|
+
* Price distance counted as one pip — `0.0001` for most FX pairs, `0.01` for
|
|
695
|
+
* JPY crosses. Inferred from the feed's decimal count when omitted, which
|
|
696
|
+
* follows the usual FX convention and is wrong for metals, indices and
|
|
697
|
+
* crypto. Pass it explicitly if pips matter.
|
|
698
|
+
*/
|
|
699
|
+
pipSize?: number;
|
|
700
|
+
/** Units per lot (e.g. `100` for XAUUSD, `100000` for most FX pairs). Default `1`. */
|
|
701
|
+
contractSize?: number;
|
|
702
|
+
/** Account-currency value of one price unit per contract unit. Default `1`. */
|
|
703
|
+
valuePerPoint?: number;
|
|
704
|
+
/** Symbol prefixed to money figures. Default `'$'`. */
|
|
705
|
+
currencySymbol?: string;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Account figures the position tools size themselves against.
|
|
709
|
+
*
|
|
710
|
+
* TradingView asks the user for these because it has no broker connection. A
|
|
711
|
+
* host that does know the live account should pass them here instead, and keep
|
|
712
|
+
* them current — the tool then sizes against real equity rather than a number
|
|
713
|
+
* the user typed once and forgot.
|
|
714
|
+
*
|
|
715
|
+
* Omit the block and the position tools still draw, showing price, percent,
|
|
716
|
+
* pips and risk/reward but no quantity or money amounts.
|
|
717
|
+
*/
|
|
718
|
+
interface AccountSpec {
|
|
719
|
+
/** Account equity in the account currency. */
|
|
720
|
+
size?: number;
|
|
721
|
+
/** Percent of the account risked per trade. Default `1`. */
|
|
722
|
+
riskPercent?: number;
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Text options for the on-chart P/L pill (`features.pnlPill`). The chart sums the
|
|
726
|
+
* numeric `pnl` each position level carries (`setLevels`' `pnlKey`); these only
|
|
727
|
+
* decide how that total is written.
|
|
728
|
+
*/
|
|
729
|
+
interface PnlPillConfig {
|
|
730
|
+
/** Currency code the default formatter appends after a space — `+72.65 USD`. Omit for none. */
|
|
731
|
+
currency?: string;
|
|
732
|
+
/** Replaces the default `+72.65 USD` formatter. Receives the summed P/L. */
|
|
733
|
+
format?: (pnl: number) => string;
|
|
734
|
+
/**
|
|
735
|
+
* Whether the pill starts shown. The header's P/L switch (rendered with the
|
|
736
|
+
* feature) and `setPnlPillVisible()` change it at runtime; `pnlPillToggle`
|
|
737
|
+
* reports the change so a host can persist it. Default: true.
|
|
738
|
+
*/
|
|
739
|
+
visible?: boolean;
|
|
740
|
+
}
|
|
621
741
|
interface ChartConfig {
|
|
622
742
|
container: HTMLElement;
|
|
623
743
|
theme?: Theme;
|
|
@@ -633,6 +753,17 @@ interface ChartConfig {
|
|
|
633
753
|
timeframe?: Timeframe;
|
|
634
754
|
duration?: Duration;
|
|
635
755
|
symbol?: string;
|
|
756
|
+
/**
|
|
757
|
+
* Contract specs for the current symbol. Lets measurement and position tools
|
|
758
|
+
* report pips and money instead of bare price distances. Swap it alongside
|
|
759
|
+
* the symbol via `setInstrument()`.
|
|
760
|
+
*/
|
|
761
|
+
instrument?: InstrumentSpec;
|
|
762
|
+
/**
|
|
763
|
+
* Account equity and per-trade risk used to size the Long/Short position
|
|
764
|
+
* tools. Keep it current via `setAccount()`.
|
|
765
|
+
*/
|
|
766
|
+
account?: AccountSpec;
|
|
636
767
|
/** List of symbols/ISINs the user can switch between via the symbol picker modal. */
|
|
637
768
|
isins?: string[];
|
|
638
769
|
/** Called when the user picks a symbol from the picker modal. Parent should call setSymbol() + setData(). */
|
|
@@ -856,6 +987,22 @@ interface ChartConfig {
|
|
|
856
987
|
* mode (candles still build from the LTP).
|
|
857
988
|
*/
|
|
858
989
|
showLtpPrice?: boolean;
|
|
990
|
+
/**
|
|
991
|
+
* Show a price-source dropdown in the chart header listing the given
|
|
992
|
+
* sources (e.g. `['ltp', 'bid']` for dealing feeds). Selecting an option
|
|
993
|
+
* switches `tickClosePriceSource` at runtime and emits `priceSourceChange`
|
|
994
|
+
* so the host can persist the choice. Hidden when unset or empty.
|
|
995
|
+
* Rendered by the default header layout.
|
|
996
|
+
*/
|
|
997
|
+
priceSourceSelector?: Array<'bid' | 'ask' | 'ltp'>;
|
|
998
|
+
/**
|
|
999
|
+
* Re-run `dataLoader` whenever the candle price source changes (a header
|
|
1000
|
+
* dropdown pick or `setTickClosePriceSource()`), passing the new source as
|
|
1001
|
+
* `params.priceSource`, so the historical candles are rebuilt from the
|
|
1002
|
+
* selected price and not just the live one. Set `false` to keep the old
|
|
1003
|
+
* behavior where only live ticks follow the new source. Default: `true`.
|
|
1004
|
+
*/
|
|
1005
|
+
reloadOnPriceSourceChange?: boolean;
|
|
859
1006
|
/**
|
|
860
1007
|
* When the combined count of open positions and pending orders exceeds this
|
|
861
1008
|
* number, the position render style auto-defaults to `'dot'` (compact).
|
|
@@ -986,6 +1133,16 @@ interface ChartConfig {
|
|
|
986
1133
|
* Default: `true`. Set `false` to only show them on hover/selection.
|
|
987
1134
|
*/
|
|
988
1135
|
showTradeLevelsAlways?: boolean;
|
|
1136
|
+
/**
|
|
1137
|
+
* When a level gains a new SL/TP — the host's order panel just placed it, so it
|
|
1138
|
+
* arrives via `setLevels()`, `updateLevelBracket()` or `updateDraftOrderBracket()`
|
|
1139
|
+
* — and that price sits outside the visible price range, widen (compress) the
|
|
1140
|
+
* price axis so the new line comes into view together with the candles already
|
|
1141
|
+
* on screen. Animated; the trader can drag or reset the axis afterwards as usual.
|
|
1142
|
+
* A bracket dragged on the chart is visible by construction, so this never fires
|
|
1143
|
+
* for it. Off in compare (percent) mode. Default: `false`.
|
|
1144
|
+
*/
|
|
1145
|
+
revealNewBrackets?: boolean;
|
|
989
1146
|
/**
|
|
990
1147
|
* Show the candle countdown timer on the right price axis, just below
|
|
991
1148
|
* the live price tag. Subject to the same `candleCountdownTimeframes`
|
|
@@ -1001,6 +1158,40 @@ interface ChartConfig {
|
|
|
1001
1158
|
* Clamped to `[1, 3]`. Default: `1`.
|
|
1002
1159
|
*/
|
|
1003
1160
|
tradeLevelButtonScale?: number;
|
|
1161
|
+
/**
|
|
1162
|
+
* Shrinks the main-level info box — the on-chart position / order tag with its P/L,
|
|
1163
|
+
* side, lots and ✎ × buttons. Font, padding, row height, grip and buttons scale
|
|
1164
|
+
* together, hit areas included; `0.6` is roughly half the area of the default tag.
|
|
1165
|
+
* SL/TP bracket pills are unaffected. Clamped to `[0.5, 1]`. Default: `1`.
|
|
1166
|
+
*/
|
|
1167
|
+
tradeLevelBadgeScale?: number;
|
|
1168
|
+
/**
|
|
1169
|
+
* Where the main-level info box sits horizontally. `'auto'` (default): centred on the
|
|
1170
|
+
* chart, or over the level's time anchor with `features.orderLineTimeDrag`. `'left'`:
|
|
1171
|
+
* the tag's home is the plot's left edge, like an axis label, whatever the open price
|
|
1172
|
+
* or time — so it never covers the candles until the trader decides otherwise. With
|
|
1173
|
+
* `features.orderLineTimeDrag` a `timeDraggable` tag can still be dragged along the
|
|
1174
|
+
* time axis, and the drop is remembered exactly as before. Default: `'auto'`.
|
|
1175
|
+
*/
|
|
1176
|
+
tradeLevelBadgeAnchor?: 'auto' | 'left';
|
|
1177
|
+
/**
|
|
1178
|
+
* What the SL/TP bracket pills show.
|
|
1179
|
+
*
|
|
1180
|
+
* `'price'` (default) renders the bracket price — `SL 4159.00`.
|
|
1181
|
+
* `'amount'` renders the money the position gains or loses if that bracket
|
|
1182
|
+
* is hit — `SL -$290.80` — computed from the level's `lots`, `contractSize`
|
|
1183
|
+
* and `valuePerPoint`. Falls back to the price for any level lacking the
|
|
1184
|
+
* data needed to compute it, so a partial rollout degrades gracefully.
|
|
1185
|
+
* `'priceAndAmount'` keeps the price but puts the currency symbol in front
|
|
1186
|
+
* of it — `SL $1.27859` — and appends the P/L while the bracket is being
|
|
1187
|
+
* dragged: `SL $1.27859 -$29.08`.
|
|
1188
|
+
*/
|
|
1189
|
+
bracketLabelMode?: 'price' | 'amount' | 'priceAndAmount';
|
|
1190
|
+
/**
|
|
1191
|
+
* Currency symbol for SL/TP amounts, used when `bracketLabelMode: 'amount'`
|
|
1192
|
+
* and the level does not carry its own `currencySymbol`. Default `'$'`.
|
|
1193
|
+
*/
|
|
1194
|
+
currencySymbol?: string;
|
|
1004
1195
|
/**
|
|
1005
1196
|
* When `true`, a theme toggle (Dark / Light) is shown in the Settings dialog.
|
|
1006
1197
|
* Default: `false` — the toggle is hidden.
|
|
@@ -1033,7 +1224,12 @@ interface ChartConfig {
|
|
|
1033
1224
|
* (preferred for branded designs that still want a link affordance)
|
|
1034
1225
|
*/
|
|
1035
1226
|
symbolNameDecoration?: 'underline' | 'none' | 'hover';
|
|
1036
|
-
/**
|
|
1227
|
+
/**
|
|
1228
|
+
* Called with the clicked price when the user picks **Alert** on the trade
|
|
1229
|
+
* action bar (`features.tradeActionBar`), and with the current market price
|
|
1230
|
+
* (live ask, else bid, else last close) from the **Alert** entry of the
|
|
1231
|
+
* advanced header's ⋯ menu (`headerOverflowMenu`). Omit to leave both out.
|
|
1232
|
+
*/
|
|
1037
1233
|
onAddAlert?: (price: number) => void;
|
|
1038
1234
|
/**
|
|
1039
1235
|
* Header layout variant. Default `'simple'`.
|
|
@@ -1104,6 +1300,39 @@ interface ChartConfig {
|
|
|
1104
1300
|
* (a one-time `console.warn` is logged at init).
|
|
1105
1301
|
*/
|
|
1106
1302
|
enableSnapshot?: boolean;
|
|
1303
|
+
/**
|
|
1304
|
+
* Put a crosshair on/off switch in the header (advanced toolbar, default top
|
|
1305
|
+
* bar and the compact per-pane strip). The crosshair itself stays on by default (`crosshairEnabled`), so
|
|
1306
|
+
* the icon starts tinted; clicking it calls `setCrosshairEnabled(false)` — the
|
|
1307
|
+
* icon drops to its plain state and the crosshair (with the floating "place
|
|
1308
|
+
* order at this price" button that rides on it) disappears until the icon is
|
|
1309
|
+
* clicked again. Emits `crosshairToggle` for the host to persist the choice.
|
|
1310
|
+
* Default: false.
|
|
1311
|
+
*/
|
|
1312
|
+
enableCrossHairHeader?: boolean;
|
|
1313
|
+
/**
|
|
1314
|
+
* @deprecated Use `enableCrossHairHeader`. Kept as an alias so existing
|
|
1315
|
+
* consumers keep their header switch — either flag being `true` renders it.
|
|
1316
|
+
*/
|
|
1317
|
+
enableCrosshairToggle?: boolean;
|
|
1318
|
+
/**
|
|
1319
|
+
* Advanced header only (`headerLayout: 'advanced'`): fold Indicators, Compare,
|
|
1320
|
+
* Snapshot and Chart settings into one ⋯ menu at the right end of the bar, and
|
|
1321
|
+
* make the Layout button icon-only, so the right cluster stays short next to
|
|
1322
|
+
* the crosshair and P/L switches. Each folded item keeps its behaviour — the
|
|
1323
|
+
* Indicators entry opens the same searchable list. Default: false.
|
|
1324
|
+
*/
|
|
1325
|
+
headerOverflowMenu?: boolean;
|
|
1326
|
+
/** Currency code and formatter for the on-chart P/L pill — see `features.pnlPill`. */
|
|
1327
|
+
pnlPill?: PnlPillConfig;
|
|
1328
|
+
/**
|
|
1329
|
+
* Timeframes offered in the header, in this order — the advanced toolbar's pill row,
|
|
1330
|
+
* the classic top bar's dropdown, and the compact header's ⌄ menu (its six fixed pills
|
|
1331
|
+
* come first; the rest of this list fills the menu). Omit to keep the classic set, so
|
|
1332
|
+
* `3m` / `4m` / `10m` / `30m` only appear for hosts that list them. Every value must be
|
|
1333
|
+
* a `Timeframe` the chart can load or aggregate (see `aggregateFrom`).
|
|
1334
|
+
*/
|
|
1335
|
+
timeframes?: Timeframe[];
|
|
1107
1336
|
/**
|
|
1108
1337
|
* Opt-in feature flags. All flags default to `false` / disabled so existing
|
|
1109
1338
|
* consumers are completely unaffected when this field is omitted.
|
|
@@ -1118,11 +1347,56 @@ interface ChartConfig {
|
|
|
1118
1347
|
* Enable horizontal (time-axis) order-line dragging: a level whose `timeDraggable`
|
|
1119
1348
|
* is true can have its info-box badge dragged left/right to re-anchor the order to
|
|
1120
1349
|
* a different candle (price stays locked), emitting `orderLineMoved` on release.
|
|
1350
|
+
* Levels that can also be price-dragged (pending orders, entry-editable positions)
|
|
1351
|
+
* keep that: the first movement of a badge grab decides the axis — sideways moves
|
|
1352
|
+
* the time anchor, up/down moves the price as before.
|
|
1121
1353
|
* This is the broker-gating seam — hosts (e.g. the Hankotrade app) enable it only
|
|
1122
1354
|
* for their flagged users. When `false` / omitted, behavior is unchanged.
|
|
1123
1355
|
* Default: false.
|
|
1124
1356
|
*/
|
|
1125
1357
|
orderLineTimeDrag?: boolean;
|
|
1358
|
+
/**
|
|
1359
|
+
* Enables the AWT-2642 forecasting/drawing work as one switch:
|
|
1360
|
+
*
|
|
1361
|
+
* - **Long Position** / **Short Position** in a new **Forecasting** group
|
|
1362
|
+
* in the drawing toolbar. Drawings only — nothing reaches the broker.
|
|
1363
|
+
* - **Brush** and **Highlighter** draw freehand (press, drag, release)
|
|
1364
|
+
* instead of dropping one point per click.
|
|
1365
|
+
* - **Ruler** reports percent, pips, calendar duration and volume instead
|
|
1366
|
+
* of just a bar count and raw price delta.
|
|
1367
|
+
*
|
|
1368
|
+
* One flag rather than three because they ship and roll back together —
|
|
1369
|
+
* a broker either has the reworked drawing tools or it doesn't.
|
|
1370
|
+
*
|
|
1371
|
+
* Off by default: enabling it changes the toolbar and the gesture of two
|
|
1372
|
+
* existing tools, so hosts opt in. With it off the chart behaves exactly
|
|
1373
|
+
* as it did before these tools existed. Default: false.
|
|
1374
|
+
*
|
|
1375
|
+
* Position quantity and money amounts additionally need `account`, and
|
|
1376
|
+
* pips on both the position tools and the ruler come from `instrument`.
|
|
1377
|
+
*/
|
|
1378
|
+
enableForecasting?: boolean;
|
|
1379
|
+
/**
|
|
1380
|
+
* Floating on-chart P/L pill — `⋮⋮ 3 POS +72.65 USD | ◎ ✕` — summarising the
|
|
1381
|
+
* open positions passed through `setLevels`: their count and the sum of the
|
|
1382
|
+
* numeric `pnl` each carries (the chart computes no money of its own).
|
|
1383
|
+
* A click on the body fans every position badge out on the chart (clustered
|
|
1384
|
+
* levels expand, TFC is switched on if needed) and lights the accent ring;
|
|
1385
|
+
* click again to collapse. Draggable within the plot, double-click puts it
|
|
1386
|
+
* back top-right. ◎ emits `bulkLevelsRequested` for the host's Bulk Levels dialog; the amber ✕ emits `pnlPillCloseAll` and the host closes the
|
|
1387
|
+
* positions. Hidden while there are no positions. Text is shaped by
|
|
1388
|
+
* top-level `pnlPill`. Default: false.
|
|
1389
|
+
*/
|
|
1390
|
+
pnlPill?: boolean;
|
|
1391
|
+
/**
|
|
1392
|
+
* Replace the two-row pending-order popup that the trade button opens with a
|
|
1393
|
+
* segmented action bar at the clicked price — `Alert | Pending | SL | TP | TSL | ×`,
|
|
1394
|
+
* no price readout (the axis shows it). Alert calls `onAddAlert` (chip only
|
|
1395
|
+
* shown when that is set); Pending opens the Buy/Sell Limit/Stop list as a
|
|
1396
|
+
* sub-menu above the bar; SL / TP / TSL emit `bulkLevelsRequested` for the
|
|
1397
|
+
* host's Bulk Levels dialog. Default: false.
|
|
1398
|
+
*/
|
|
1399
|
+
tradeActionBar?: boolean;
|
|
1126
1400
|
};
|
|
1127
1401
|
/**
|
|
1128
1402
|
* Fetches historical OHLC bars for a compare symbol. When provided, the
|
|
@@ -1186,12 +1460,42 @@ interface ChartConfig {
|
|
|
1186
1460
|
* allowing the user to enable/disable TFC at runtime.
|
|
1187
1461
|
*/
|
|
1188
1462
|
tfcEnabled?: boolean;
|
|
1463
|
+
/**
|
|
1464
|
+
* Draw the mouse crosshair and, with it, the floating "place order at this
|
|
1465
|
+
* price" button that rides along its horizontal line. `false` hides both: no
|
|
1466
|
+
* crosshair lines or axis readouts, `crosshair` events carry `null`, mirrored
|
|
1467
|
+
* `setCrosshair()` calls are ignored, the mobile long-press crosshair does not
|
|
1468
|
+
* arm, and the trade button stays hidden until the crosshair is enabled again.
|
|
1469
|
+
* Trade levels, drawings and the TFC state are unaffected. Runtime toggle:
|
|
1470
|
+
* `setCrosshairEnabled()`. Default: true.
|
|
1471
|
+
*/
|
|
1472
|
+
crosshairEnabled?: boolean;
|
|
1189
1473
|
/**
|
|
1190
1474
|
* Snap a horizontally-dragged order line to the nearest candle on drag release.
|
|
1191
1475
|
* Only relevant when `features.orderLineTimeDrag` is enabled. When `false`, the badge
|
|
1192
1476
|
* keeps the exact (interpolated) time it was released at. Default: `true`.
|
|
1193
1477
|
*/
|
|
1194
1478
|
orderLineDragSnap?: boolean;
|
|
1479
|
+
/**
|
|
1480
|
+
* Remember where each horizontally-dragged order-line badge was dropped in
|
|
1481
|
+
* `localStorage` (keyed by the level's label, i.e. your order/trade id) so it comes back
|
|
1482
|
+
* to the same candle after a page reload — even when the next `setLevels()` payload
|
|
1483
|
+
* carries the order's original `timestamp`. A persisted anchor takes precedence over
|
|
1484
|
+
* the level's `timestamp` until the label is dragged again. Bounded to the 500 most
|
|
1485
|
+
* recently dragged labels. Only relevant when `features.orderLineTimeDrag` is enabled.
|
|
1486
|
+
* Default: `true`.
|
|
1487
|
+
*/
|
|
1488
|
+
orderLineAnchorPersistence?: boolean;
|
|
1489
|
+
/**
|
|
1490
|
+
* Where a `timeDraggable` level's badge sits before the user has dragged it:
|
|
1491
|
+
* - `'timestamp'` (default): over the candle at the level's `timestamp`, as before.
|
|
1492
|
+
* - `'center'`: at the chart's horizontal center, ignoring the level's `timestamp`, so a
|
|
1493
|
+
* freshly placed market order arrives mid-chart instead of pinned to the latest candle.
|
|
1494
|
+
* Once the user drags the badge it is anchored to (and persisted at) the dropped candle.
|
|
1495
|
+
* Levels that are not `timeDraggable` always honor their `timestamp`.
|
|
1496
|
+
* Only relevant when `features.orderLineTimeDrag` is enabled.
|
|
1497
|
+
*/
|
|
1498
|
+
orderLineDefaultAnchor?: 'timestamp' | 'center';
|
|
1195
1499
|
}
|
|
1196
1500
|
interface IndicatorResult {
|
|
1197
1501
|
index: number;
|
|
@@ -1215,7 +1519,7 @@ interface IIndicator {
|
|
|
1215
1519
|
getValueRange?(results: IndicatorResult[]): PriceRange;
|
|
1216
1520
|
render(ctx: CanvasRenderingContext2D, results: IndicatorResult[], scaleManager: ScaleManager, viewport: Viewport, chartHeight: number, rangeOverride?: PriceRange): void;
|
|
1217
1521
|
}
|
|
1218
|
-
type DrawingToolType = "horizontalLine" | "verticalLine" | "trendLine" | "rectangle" | "ellipse" | "circle" | "triangle" | "fibRetracement" | "fibExtension" | "fibChannel" | "fibProjection" | "fibFan" | "fibCircles" | "fibSpiral" | "fibTimezone" | "flatChannel" | "parallelChannel" | "disjointChannel" | "pitchfork" | "schiffPitchfork" | "modifiedSchiff" | "insidePitchfork" | "crossLine" | "trendAngle" | "arc" | "sineLine" | "rotatedRectangle" | "path" | "polyline" | "brush" | "highlighter" | "text" | "callout" | "priceLabel" | "priceNote" | "anchoredNote" | "arrowUp" | "arrowDown" | "arrowMarker" | "flag" | "volumeProfile" | "anchoredVP" | "fixedRangeVP" | "abcdPattern" | "gartleyPattern" | "batPattern" | "butterflyPattern" | "crabPattern" | "sharkPattern" | "cypherPattern" | "headShoulders" | "trianglePattern" | "threeDrives" | "elliottImpulse" | "elliottCorrective" | "elliottTriangle" | "elliottWxy" | "elliottCombination" | "gannFan" | "gannSquare" | "gannBox" | "priceRange" | "dateRange" | "datePriceRange" | "ruler" | "regressionTrend" | "projection" | "cyclicLines" | "timeCycles" | "priceProjection" | "ghostFeed";
|
|
1522
|
+
type DrawingToolType = "horizontalLine" | "verticalLine" | "trendLine" | "rectangle" | "ellipse" | "circle" | "triangle" | "fibRetracement" | "fibExtension" | "fibChannel" | "fibProjection" | "fibFan" | "fibCircles" | "fibSpiral" | "fibTimezone" | "flatChannel" | "parallelChannel" | "disjointChannel" | "pitchfork" | "schiffPitchfork" | "modifiedSchiff" | "insidePitchfork" | "crossLine" | "trendAngle" | "arc" | "sineLine" | "rotatedRectangle" | "path" | "polyline" | "brush" | "highlighter" | "text" | "callout" | "priceLabel" | "priceNote" | "anchoredNote" | "arrowUp" | "arrowDown" | "arrowMarker" | "flag" | "volumeProfile" | "anchoredVP" | "fixedRangeVP" | "abcdPattern" | "gartleyPattern" | "batPattern" | "butterflyPattern" | "crabPattern" | "sharkPattern" | "cypherPattern" | "headShoulders" | "trianglePattern" | "threeDrives" | "elliottImpulse" | "elliottCorrective" | "elliottTriangle" | "elliottWxy" | "elliottCombination" | "gannFan" | "gannSquare" | "gannBox" | "priceRange" | "dateRange" | "datePriceRange" | "ruler" | "regressionTrend" | "projection" | "cyclicLines" | "timeCycles" | "priceProjection" | "ghostFeed" | "longPosition" | "shortPosition";
|
|
1219
1523
|
interface DrawingPoint {
|
|
1220
1524
|
barIndex: number;
|
|
1221
1525
|
price: number;
|
|
@@ -1226,6 +1530,15 @@ interface DrawingPoint {
|
|
|
1226
1530
|
interface DrawingHandle {
|
|
1227
1531
|
pointIndex: number;
|
|
1228
1532
|
cursor: string;
|
|
1533
|
+
/**
|
|
1534
|
+
* Corners that are a mixture of two stored points — a rectangle's top-right
|
|
1535
|
+
* is `(p2.barIndex, p1.price)` — set these instead of relying on
|
|
1536
|
+
* `pointIndex` alone. The drag then writes the x to `points[xPointIndex]`
|
|
1537
|
+
* and the y to `points[yPointIndex]`, which is what makes all four corners
|
|
1538
|
+
* of a two-point shape draggable rather than just the two stored ones.
|
|
1539
|
+
*/
|
|
1540
|
+
xPointIndex?: number;
|
|
1541
|
+
yPointIndex?: number;
|
|
1229
1542
|
}
|
|
1230
1543
|
/** Base per-instance style fields applicable to every drawing. */
|
|
1231
1544
|
interface DrawingStyle {
|
|
@@ -1266,6 +1579,23 @@ interface DrawingFibStyle extends DrawingStyle {
|
|
|
1266
1579
|
}
|
|
1267
1580
|
/** Union of all drawing style shapes. */
|
|
1268
1581
|
type AnyDrawingStyle = DrawingStyle | DrawingTextStyle | DrawingFibStyle;
|
|
1582
|
+
/**
|
|
1583
|
+
* Extra context a drawing may need at render time, beyond geometry.
|
|
1584
|
+
*
|
|
1585
|
+
* Passed as one optional object rather than more positional parameters: almost
|
|
1586
|
+
* no drawing needs any of it, and the ones that do (measurement and position
|
|
1587
|
+
* tools) need several fields at once.
|
|
1588
|
+
*/
|
|
1589
|
+
interface DrawingRenderContext {
|
|
1590
|
+
/** Resolved contract specs — pip size, contract size, money conversion. */
|
|
1591
|
+
instrument?: ResolvedInstrument;
|
|
1592
|
+
/** Bars currently loaded, for tools that summarise a range. */
|
|
1593
|
+
bars?: readonly OHLCVBar[];
|
|
1594
|
+
/** Account equity and per-trade risk, for tools that size a position. */
|
|
1595
|
+
account?: AccountSpec;
|
|
1596
|
+
/** Host feature gates, for tools whose output is flagged. */
|
|
1597
|
+
features?: ChartConfig['features'];
|
|
1598
|
+
}
|
|
1269
1599
|
interface IDrawing {
|
|
1270
1600
|
id: string;
|
|
1271
1601
|
type: DrawingToolType;
|
|
@@ -1276,8 +1606,17 @@ interface IDrawing {
|
|
|
1276
1606
|
text?: string;
|
|
1277
1607
|
/** Optional per-instance style override; falls back to theme defaults when absent. */
|
|
1278
1608
|
style?: AnyDrawingStyle;
|
|
1279
|
-
render(ctx: CanvasRenderingContext2D, scale: ScaleManager, viewport: Viewport, priceRange: PriceRange, chartW: number, chartH: number, isSelected: boolean, pricePrecision?: number, theme?: ChartTheme): void;
|
|
1609
|
+
render(ctx: CanvasRenderingContext2D, scale: ScaleManager, viewport: Viewport, priceRange: PriceRange, chartW: number, chartH: number, isSelected: boolean, pricePrecision?: number, theme?: ChartTheme, context?: DrawingRenderContext): void;
|
|
1280
1610
|
hitTest(x: number, y: number, scale: ScaleManager, viewport: Viewport, priceRange: PriceRange, chartW: number, chartH: number): boolean;
|
|
1611
|
+
/**
|
|
1612
|
+
* Called once, immediately after the drawing is completed.
|
|
1613
|
+
*
|
|
1614
|
+
* Lets a tool derive anchors it could not collect during placement — the
|
|
1615
|
+
* position tools take entry and target from two clicks, then materialise a
|
|
1616
|
+
* stop from the default risk/reward here rather than making the user click
|
|
1617
|
+
* a third time.
|
|
1618
|
+
*/
|
|
1619
|
+
onPlaced?(): void;
|
|
1281
1620
|
/** Returns the handle under (x, y), or null if none */
|
|
1282
1621
|
getHandle(x: number, y: number, scale: ScaleManager, viewport: Viewport, priceRange: PriceRange, chartW: number, chartH: number): DrawingHandle | null;
|
|
1283
1622
|
}
|
|
@@ -1429,6 +1768,14 @@ type ChartEventMap = {
|
|
|
1429
1768
|
seriesChange: {
|
|
1430
1769
|
series: SeriesType;
|
|
1431
1770
|
};
|
|
1771
|
+
/** Emitted when the user picks a price source (BID / ASK / LTP) from the
|
|
1772
|
+
* header dropdown (`priceSourceSelector`). Not emitted for programmatic
|
|
1773
|
+
* `setTickClosePriceSource()` calls. By the time this fires the engine has
|
|
1774
|
+
* already switched the live source and (unless `reloadOnPriceSourceChange`
|
|
1775
|
+
* is `false`) started re-fetching history via `dataLoader`. */
|
|
1776
|
+
priceSourceChange: {
|
|
1777
|
+
source: 'bid' | 'ask' | 'ltp';
|
|
1778
|
+
};
|
|
1432
1779
|
streamStatus: {
|
|
1433
1780
|
status: StreamStatus;
|
|
1434
1781
|
};
|
|
@@ -1439,6 +1786,8 @@ type ChartEventMap = {
|
|
|
1439
1786
|
interval: string;
|
|
1440
1787
|
start: Date;
|
|
1441
1788
|
end: Date;
|
|
1789
|
+
/** Candle price source the bars were requested with (see `DataLoaderParams.priceSource`). */
|
|
1790
|
+
priceSource: 'bid' | 'ask' | 'ltp';
|
|
1442
1791
|
};
|
|
1443
1792
|
/** Emitted when the user clicks the × button on a trade, position, or bracket (SL/TP) level. */
|
|
1444
1793
|
tradeLevelClose: {
|
|
@@ -1554,6 +1903,40 @@ type ChartEventMap = {
|
|
|
1554
1903
|
tfcToggle: {
|
|
1555
1904
|
enabled: boolean;
|
|
1556
1905
|
};
|
|
1906
|
+
/** Crosshair switched on or off — via the header switch (`enableCrossHairHeader`) or `setCrosshairEnabled()`. */
|
|
1907
|
+
crosshairToggle: {
|
|
1908
|
+
enabled: boolean;
|
|
1909
|
+
};
|
|
1910
|
+
/** The P/L pill was shown or hidden — via the header's P/L switch or `setPnlPillVisible()` (`features.pnlPill`). */
|
|
1911
|
+
pnlPillToggle: {
|
|
1912
|
+
visible: boolean;
|
|
1913
|
+
};
|
|
1914
|
+
/**
|
|
1915
|
+
* Open the host's Bulk Levels dialog — one SL / TP / TSL for every open position of
|
|
1916
|
+
* the symbol. From the trade action bar (`source: 'actionBar'`) `kind` is the chip
|
|
1917
|
+
* clicked and `price` the clicked price; from the P/L pill's ◎ (`source: 'pill'`)
|
|
1918
|
+
* `kind` is `'sl'` and `price` is `null` — no level was clicked, so the dialog opens
|
|
1919
|
+
* with an empty price. The chart never calls a broker.
|
|
1920
|
+
*/
|
|
1921
|
+
bulkLevelsRequested: {
|
|
1922
|
+
kind: 'sl' | 'tp' | 'tsl';
|
|
1923
|
+
price: number | null;
|
|
1924
|
+
isFullscreen: boolean;
|
|
1925
|
+
source: 'actionBar' | 'pill';
|
|
1926
|
+
};
|
|
1927
|
+
/**
|
|
1928
|
+
* The on-chart P/L pill's ✕ (`features.pnlPill`). Carries every position the pill
|
|
1929
|
+
* counted — the host closes them; the chart never calls a broker. `pnl` is the
|
|
1930
|
+
* summed P/L, or null when no position carried one. `data` are the rows given to
|
|
1931
|
+
* `setLevels`, in the same order as `labels`.
|
|
1932
|
+
*/
|
|
1933
|
+
pnlPillCloseAll: {
|
|
1934
|
+
count: number;
|
|
1935
|
+
pnl: number | null;
|
|
1936
|
+
labels: string[];
|
|
1937
|
+
data: unknown[];
|
|
1938
|
+
isFullscreen: boolean;
|
|
1939
|
+
};
|
|
1557
1940
|
/** Emitted whenever any dismissible UI (flyout, modal, dropdown, popover) opens or closes.
|
|
1558
1941
|
* Hosts (native wrappers, PWAs) listen to track whether a back button / gesture should
|
|
1559
1942
|
* dismiss chart UI vs. navigate. Pair with `dismissAllUI()` to wire platform back events. */
|
|
@@ -1744,10 +2127,34 @@ interface PositionLevel {
|
|
|
1744
2127
|
stopLossPrice?: number;
|
|
1745
2128
|
/** Data object for the SL bracket — returned in SL-related events instead of the parent's `data`. */
|
|
1746
2129
|
stopLossData?: unknown;
|
|
2130
|
+
/**
|
|
2131
|
+
* The stop-loss is a trailing stop. A trade with a trail always has a working stop
|
|
2132
|
+
* at `stopLossPrice`, so the line still renders — its pill reads "TSL" instead of
|
|
2133
|
+
* "SL" — but it is read-only on the chart (no drag handle, no ×): the trail lives
|
|
2134
|
+
* in pips and is edited from the host's order panel. Default: false.
|
|
2135
|
+
*/
|
|
2136
|
+
stopLossTrailing?: boolean;
|
|
1747
2137
|
/** Take-profit price. Renders as a secondary dashed line above entry (buy) or below (sell). Draggable — emits `tradeLevelBracketDrag`. */
|
|
1748
2138
|
takeProfitPrice?: number;
|
|
1749
2139
|
/** Data object for the TP bracket — returned in TP-related events instead of the parent's `data`. */
|
|
1750
2140
|
takeProfitData?: unknown;
|
|
2141
|
+
/**
|
|
2142
|
+
* Units per lot for this instrument (e.g. `100` for XAUUSD, `100000` for most
|
|
2143
|
+
* FX pairs). Only used when `bracketLabelMode: 'amount'`, to convert an SL/TP
|
|
2144
|
+
* price distance into money. Default `1`.
|
|
2145
|
+
*/
|
|
2146
|
+
contractSize?: number;
|
|
2147
|
+
/**
|
|
2148
|
+
* Account-currency value of one price unit per contract unit — folds in any
|
|
2149
|
+
* quote → account conversion. Only used when `bracketLabelMode: 'amount'`.
|
|
2150
|
+
* Default `1`.
|
|
2151
|
+
*/
|
|
2152
|
+
valuePerPoint?: number;
|
|
2153
|
+
/**
|
|
2154
|
+
* Currency symbol for this level's SL/TP amounts. Falls back to
|
|
2155
|
+
* `ChartConfig.currencySymbol`, then `'$'`.
|
|
2156
|
+
*/
|
|
2157
|
+
currencySymbol?: string;
|
|
1751
2158
|
/**
|
|
1752
2159
|
* When true, the entry price line becomes draggable — renders a grip handle and emits
|
|
1753
2160
|
* `tradeLevelEdit` with `field: 'main'` on confirm. Use this for pending entry orders
|
|
@@ -1774,7 +2181,9 @@ interface PositionLevel {
|
|
|
1774
2181
|
/**
|
|
1775
2182
|
* When true (and `ChartConfig.features.orderLineTimeDrag` is enabled), the badge can be
|
|
1776
2183
|
* dragged horizontally to re-anchor the order to a different candle (price stays locked).
|
|
1777
|
-
* Emits `orderLineMoved` on release.
|
|
2184
|
+
* Emits `orderLineMoved` on release. An `entryPriceEditable` position keeps its vertical
|
|
2185
|
+
* price drag too: the badge follows the drag direction (sideways = time, up/down = price).
|
|
2186
|
+
* Default: false.
|
|
1778
2187
|
*/
|
|
1779
2188
|
timeDraggable?: boolean;
|
|
1780
2189
|
/**
|
|
@@ -1807,6 +2216,8 @@ interface PendingOrderLevel {
|
|
|
1807
2216
|
stopLossPrice?: number;
|
|
1808
2217
|
/** Data object for the SL bracket — returned in SL-related events instead of the parent's `data`. */
|
|
1809
2218
|
stopLossData?: unknown;
|
|
2219
|
+
/** The stop-loss is a trailing stop — pill reads "TSL", read-only on the chart. See `PositionLevel.stopLossTrailing`. */
|
|
2220
|
+
stopLossTrailing?: boolean;
|
|
1810
2221
|
/**
|
|
1811
2222
|
* Take-profit price. Renders as a secondary dashed line above the order price
|
|
1812
2223
|
* (for buy orders) or below (for sell orders). Draggable — emits `tradeLevelBracketDrag`.
|
|
@@ -1830,8 +2241,10 @@ interface PendingOrderLevel {
|
|
|
1830
2241
|
timestamp?: number;
|
|
1831
2242
|
/**
|
|
1832
2243
|
* When true (and `ChartConfig.features.orderLineTimeDrag` is enabled), the badge can be
|
|
1833
|
-
* dragged horizontally to re-anchor the order to a different candle
|
|
1834
|
-
*
|
|
2244
|
+
* dragged horizontally to re-anchor the order to a different candle, emitting
|
|
2245
|
+
* `orderLineMoved` on release. The order stays price-draggable: the badge follows the
|
|
2246
|
+
* drag direction — sideways moves the time anchor (price locked), up/down moves the
|
|
2247
|
+
* entry price exactly as without this flag. Default: false.
|
|
1835
2248
|
*/
|
|
1836
2249
|
timeDraggable?: boolean;
|
|
1837
2250
|
/** Your original order object. Returned as-is in events. The library never inspects this. */
|
|
@@ -1840,6 +2253,61 @@ interface PendingOrderLevel {
|
|
|
1840
2253
|
/** Union of all level types — use this wherever a level is accepted or stored. */
|
|
1841
2254
|
type AnyLevel = TradeLevel | PositionLevel | PendingOrderLevel;
|
|
1842
2255
|
|
|
2256
|
+
/**
|
|
2257
|
+
* Instrument specs, with every gap filled in.
|
|
2258
|
+
*
|
|
2259
|
+
* The chart has never known what a price *means* — see `tradeMath.ts`, which
|
|
2260
|
+
* takes contract specs per trade level for exactly this reason. Tools that
|
|
2261
|
+
* report a distance in pips or in money need the same information at chart
|
|
2262
|
+
* scope, so hosts supply an `instrument` block on `ChartConfig` and this module
|
|
2263
|
+
* resolves it against sensible fallbacks.
|
|
2264
|
+
*/
|
|
2265
|
+
interface ResolvedInstrument {
|
|
2266
|
+
/** Price distance counted as one pip. */
|
|
2267
|
+
pipSize: number;
|
|
2268
|
+
/** Units per lot (e.g. `100` for XAUUSD, `100000` for most FX pairs). */
|
|
2269
|
+
contractSize: number;
|
|
2270
|
+
/** Account-currency value of one price unit per contract unit. */
|
|
2271
|
+
valuePerPoint: number;
|
|
2272
|
+
/** Symbol prefixed to money figures. */
|
|
2273
|
+
currencySymbol: string;
|
|
2274
|
+
/** True when `pipSize` was guessed from price precision rather than supplied. */
|
|
2275
|
+
pipSizeInferred: boolean;
|
|
2276
|
+
}
|
|
2277
|
+
/**
|
|
2278
|
+
* Pip size guessed from how many decimals the feed quotes.
|
|
2279
|
+
*
|
|
2280
|
+
* Feeds that quote fractional pips carry one digit more than the pip itself —
|
|
2281
|
+
* five decimals on EURUSD (1.08531) and three on USDJPY (151.234) both mean the
|
|
2282
|
+
* pip is the second-to-last digit. Two- and four-decimal feeds quote whole pips,
|
|
2283
|
+
* so the pip is the last digit.
|
|
2284
|
+
*
|
|
2285
|
+
* This is a convention, not a fact about the instrument: metals, indices and
|
|
2286
|
+
* crypto all break it. Hosts that care should pass `pipSize` explicitly.
|
|
2287
|
+
*/
|
|
2288
|
+
declare function inferPipSize(pricePrecision: number): number;
|
|
2289
|
+
/** Fills in whatever the host left out. */
|
|
2290
|
+
declare function resolveInstrument(spec: InstrumentSpec | undefined, pricePrecision: number): ResolvedInstrument;
|
|
2291
|
+
/** A price distance expressed in pips. Sign follows the distance. */
|
|
2292
|
+
declare function toPips(priceDelta: number, pipSize: number): number;
|
|
2293
|
+
/**
|
|
2294
|
+
* A price distance expressed in account currency for a given size, or `null`
|
|
2295
|
+
* when the host hasn't supplied enough to convert. Callers fall back to showing
|
|
2296
|
+
* the price rather than rendering a number that isn't money.
|
|
2297
|
+
*/
|
|
2298
|
+
declare function toMoney(priceDelta: number, lots: number, instrument: ResolvedInstrument): number | null;
|
|
2299
|
+
/**
|
|
2300
|
+
* Compact volume for a readout — `102.27K`, `4.5M`. Full precision would push
|
|
2301
|
+
* the label wider than the box it sits in.
|
|
2302
|
+
*/
|
|
2303
|
+
declare function formatVolume(volume: number): string;
|
|
2304
|
+
/**
|
|
2305
|
+
* Calendar span between two timestamps, in the largest two units that apply —
|
|
2306
|
+
* `9d 4h`, `4h 30m`, `45m`. Bar counts alone don't tell a trader how long a move
|
|
2307
|
+
* actually took once weekends and session gaps are in the data.
|
|
2308
|
+
*/
|
|
2309
|
+
declare function formatDuration(ms: number): string;
|
|
2310
|
+
|
|
1843
2311
|
type PriceSource = 'open' | 'high' | 'low' | 'close';
|
|
1844
2312
|
|
|
1845
2313
|
declare class SMA implements IIndicator {
|
|
@@ -1901,4 +2369,4 @@ declare class MACD implements IIndicator {
|
|
|
1901
2369
|
render(ctx: CanvasRenderingContext2D, results: IndicatorResult[], scale: ScaleManager, viewport: Viewport, paneHeight: number, rangeOverride?: PriceRange): void;
|
|
1902
2370
|
}
|
|
1903
2371
|
|
|
1904
|
-
export { type
|
|
2372
|
+
export { type DataLoaderParams as $, type AccountSpec as A, BollingerBands as B, type ChartConfig as C, type Duration as D, type ChartThemeUi as E, type CrosshairPosition as F, type CrosshairUiConfig as G, DARK_THEME as H, type IIndicator as I, DEFAULT_BOTTOM_BAR_CONFIG as J, DEFAULT_CROSSHAIR_CONFIG as K, type LayoutSyncState as L, DEFAULT_DRAWING_TOOLBAR_CONFIG as M, DEFAULT_INDICATOR_OVERLAY_CONFIG as N, type OHLCVBar as O, type PositionLevel as P, DEFAULT_LABELS as Q, type ResolvedInstrument as R, type SeriesType as S, type Timeframe as T, DEFAULT_LAYOUT_SYNC as U, type Viewport as V, DEFAULT_PRICE_AXIS_CONFIG as W, DEFAULT_TIME_AXIS_CONFIG as X, DEFAULT_TOP_BAR_CONFIG as Y, DEFAULT_TRADE_BUTTON_CONFIG as Z, DEFAULT_UI_CONFIG as _, type IndicatorParams as a, type DeepPartial$1 as a0, type DeepPartialChartTheme as a1, type DialogLabels as a2, type DrawingToolbarColors as a3, type DrawingToolbarLabels as a4, type DrawingToolbarUiConfig as a5, EMA as a6, type IndicatorOverlayColors as a7, type IndicatorOverlayUiConfig as a8, type IndicatorResult as a9, type TradeLabels as aA, type TradeLevel as aB, type TradeLevelColors as aC, type TradePanelColors as aD, type UiConfig as aE, deepMergeTheme as aF, formatDuration as aG, formatVolume as aH, getAllPresets as aI, getCustomPresets as aJ, getPreset as aK, inferPipSize as aL, registerCustomPreset as aM, resolveCssVarsInTheme as aN, resolveInstrument as aO, resolveLabels as aP, resolveUiConfig as aQ, toMoney as aR, toPips as aS, unregisterCustomPreset as aT, type PriceSource as aU, type IndicatorStateEntry as aa, LAYOUT_PRESETS as ab, LIGHT_THEME as ac, type LayoutPreset as ad, MACD as ae, type OhlcLabels as af, type OrderSubmit as ag, PRESETS_BY_COUNT as ah, PRESET_COUNTS as ai, PRESET_LABEL as aj, type Padding as ak, type PendingOrderLevel as al, type PnlPillConfig as am, type PnlPillLabels as an, type PositionRenderStyle as ao, type PriceAxisUiConfig as ap, RSI as aq, SMA as ar, type Theme as as, type ThemeOverrides as at, type TimeAxisUiConfig as au, type TopBarColors as av, type TopBarLabels as aw, type TopBarUiConfig as ax, type TradeButtonUiConfig as ay, type TradeDisplayFilter as az, type ChartEventMap as b, type ChartState as c, type InstrumentSpec as d, type DrawingToolType as e, type IDrawing as f, type AnyDrawingStyle as g, type IWebSocketAdapter as h, type TradeLevelType as i, type ChartTheme as j, type AnyLevel as k, type DrawingPoint as l, ScaleManager as m, type PriceRange as n, type DrawingHandle as o, type DrawingRenderContext as p, type SerializedDrawing as q, type Tick as r, type StreamStatus as s, type ActiveIndicatorState as t, type BottomBarColors as u, type BottomBarLabels as v, type BottomBarUiConfig as w, type CanvasColorSettings as x, type ChartLabels as y, type ChartMiscLabels as z };
|