acttrader-charts 1.3.0-beta.5 → 1.3.0-beta.7

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
@@ -684,6 +684,9 @@ chart.loadData(newBars);
684
684
  chart.setSeries(series: SeriesType): this
685
685
  chart.setTheme('dark' | 'light'): this
686
686
  chart.setTimeframe(tf: Timeframe): this // change timeframe and reload data
687
+ chart.setDuration(d: Duration, timeframe?: Timeframe): this // select a duration; pairs the timeframe and reloads
688
+ chart.getDuration(): Duration | null // currently selected duration
689
+ chart.setBracketLabelMode(mode, currencySymbol?): this // SL/TP pills: 'price' (default) or 'amount'
687
690
  chart.setThemeOverrides(overrides: ThemeOverrides): this // update per-theme color overrides at runtime
688
691
  chart.setTimezone(tz: string): this // change display timezone at runtime
689
692
  chart.setVolume(show: boolean): this
@@ -888,6 +891,37 @@ Sub-pane heights are user-resizable by dragging the separator between panes.
888
891
  | `flatChannel` | Flat Channel | 2 clicks |
889
892
  | `disjointChannel` | Disjoint Channel | 3 clicks |
890
893
 
894
+ ### SL/TP bracket labels — price or amount
895
+
896
+ By default an SL/TP pill reads `SL 4159.00`. With `bracketLabelMode: 'amount'`
897
+ it reads `SL -$290.80` — the money the position gains or loses if that bracket
898
+ is hit, currency symbol in front.
899
+
900
+ The chart has no access to contract specs or the account currency, so each level
901
+ supplies what the maths needs:
902
+
903
+ ```ts
904
+ new ChartEngine({ container, bracketLabelMode: 'amount', currencySymbol: '$' });
905
+
906
+ chart.setLevels([{
907
+ label: 'POS-1', price: 4173.54, side: 'buy', lots: 0.20,
908
+ stopLossPrice: 4159.00, takeProfitPrice: 4183.00,
909
+ contractSize: 100, // units per lot (100 for XAUUSD, 100000 for most FX)
910
+ valuePerPoint: 1, // account-currency value of one price unit
911
+ currencySymbol: '$', // optional per-level override
912
+ }], 'label', 'price', 'position');
913
+ // pills render: SL -$290.80 TP +$189.20
914
+ ```
915
+
916
+ ```
917
+ amount = (bracket − entry) × direction × lots × contractSize × valuePerPoint
918
+ ```
919
+
920
+ `valuePerPoint` is where a quote → account currency conversion goes. A level
921
+ missing `lots` or `contractSize` keeps showing its price, so a partial rollout
922
+ degrades level by level rather than rendering `NaN`. Toggle at runtime with
923
+ `chart.setBracketLabelMode('amount')`.
924
+
891
925
  ### Fibonacci & Gann
892
926
 
893
927
  `fibRetracement` · `fibExtension` · `fibChannel` · `fibTimezone` · `fibCircles` · `fibSpiral` · `fibFan` · `fibProjection` · `gannFan` · `gannSquare` · `gannBox`
@@ -1001,6 +1001,24 @@ interface ChartConfig {
1001
1001
  * Clamped to `[1, 3]`. Default: `1`.
1002
1002
  */
1003
1003
  tradeLevelButtonScale?: number;
1004
+ /**
1005
+ * What the SL/TP bracket pills show.
1006
+ *
1007
+ * `'price'` (default) renders the bracket price — `SL 4159.00`.
1008
+ * `'amount'` renders the money the position gains or loses if that bracket
1009
+ * is hit — `SL -$290.80` — computed from the level's `lots`, `contractSize`
1010
+ * and `valuePerPoint`. Falls back to the price for any level lacking the
1011
+ * data needed to compute it, so a partial rollout degrades gracefully.
1012
+ * `'priceAndAmount'` keeps the price but puts the currency symbol in front
1013
+ * of it — `SL $1.27859` — and appends the P/L while the bracket is being
1014
+ * dragged: `SL $1.27859 -$29.08`.
1015
+ */
1016
+ bracketLabelMode?: 'price' | 'amount' | 'priceAndAmount';
1017
+ /**
1018
+ * Currency symbol for SL/TP amounts, used when `bracketLabelMode: 'amount'`
1019
+ * and the level does not carry its own `currencySymbol`. Default `'$'`.
1020
+ */
1021
+ currencySymbol?: string;
1004
1022
  /**
1005
1023
  * When `true`, a theme toggle (Dark / Light) is shown in the Settings dialog.
1006
1024
  * Default: `false` — the toggle is hidden.
@@ -1226,6 +1244,15 @@ interface DrawingPoint {
1226
1244
  interface DrawingHandle {
1227
1245
  pointIndex: number;
1228
1246
  cursor: string;
1247
+ /**
1248
+ * Corners that are a mixture of two stored points — a rectangle's top-right
1249
+ * is `(p2.barIndex, p1.price)` — set these instead of relying on
1250
+ * `pointIndex` alone. The drag then writes the x to `points[xPointIndex]`
1251
+ * and the y to `points[yPointIndex]`, which is what makes all four corners
1252
+ * of a two-point shape draggable rather than just the two stored ones.
1253
+ */
1254
+ xPointIndex?: number;
1255
+ yPointIndex?: number;
1229
1256
  }
1230
1257
  /** Base per-instance style fields applicable to every drawing. */
1231
1258
  interface DrawingStyle {
@@ -1748,6 +1775,23 @@ interface PositionLevel {
1748
1775
  takeProfitPrice?: number;
1749
1776
  /** Data object for the TP bracket — returned in TP-related events instead of the parent's `data`. */
1750
1777
  takeProfitData?: unknown;
1778
+ /**
1779
+ * Units per lot for this instrument (e.g. `100` for XAUUSD, `100000` for most
1780
+ * FX pairs). Only used when `bracketLabelMode: 'amount'`, to convert an SL/TP
1781
+ * price distance into money. Default `1`.
1782
+ */
1783
+ contractSize?: number;
1784
+ /**
1785
+ * Account-currency value of one price unit per contract unit — folds in any
1786
+ * quote → account conversion. Only used when `bracketLabelMode: 'amount'`.
1787
+ * Default `1`.
1788
+ */
1789
+ valuePerPoint?: number;
1790
+ /**
1791
+ * Currency symbol for this level's SL/TP amounts. Falls back to
1792
+ * `ChartConfig.currencySymbol`, then `'$'`.
1793
+ */
1794
+ currencySymbol?: string;
1751
1795
  /**
1752
1796
  * When true, the entry price line becomes draggable — renders a grip handle and emits
1753
1797
  * `tradeLevelEdit` with `field: 'main'` on confirm. Use this for pending entry orders
@@ -1901,4 +1945,4 @@ declare class MACD implements IIndicator {
1901
1945
  render(ctx: CanvasRenderingContext2D, results: IndicatorResult[], scale: ScaleManager, viewport: Viewport, paneHeight: number, rangeOverride?: PriceRange): void;
1902
1946
  }
1903
1947
 
1904
- export { type DrawingToolbarUiConfig as $, type AnyDrawingStyle as A, BollingerBands as B, type ChartConfig as C, type DrawingToolType as D, DEFAULT_CROSSHAIR_CONFIG as E, DEFAULT_DRAWING_TOOLBAR_CONFIG as F, DEFAULT_INDICATOR_OVERLAY_CONFIG as G, DEFAULT_LABELS as H, type IIndicator as I, DEFAULT_LAYOUT_SYNC as J, DEFAULT_PRICE_AXIS_CONFIG as K, type LayoutSyncState as L, DEFAULT_TIME_AXIS_CONFIG as M, DEFAULT_TOP_BAR_CONFIG as N, type OHLCVBar as O, type PriceRange as P, DEFAULT_TRADE_BUTTON_CONFIG as Q, DEFAULT_UI_CONFIG as R, type SeriesType as S, type Timeframe as T, type DataLoaderParams as U, type Viewport as V, type DeepPartial$1 as W, type DeepPartialChartTheme as X, type DialogLabels as Y, type DrawingToolbarColors as Z, type DrawingToolbarLabels as _, type IndicatorParams as a, type Duration as a0, EMA as a1, type IndicatorOverlayColors as a2, type IndicatorOverlayUiConfig as a3, type IndicatorResult as a4, type IndicatorStateEntry as a5, LAYOUT_PRESETS as a6, LIGHT_THEME as a7, type LayoutPreset as a8, MACD as a9, getAllPresets as aA, getCustomPresets as aB, getPreset as aC, registerCustomPreset as aD, resolveCssVarsInTheme as aE, resolveLabels as aF, resolveUiConfig as aG, unregisterCustomPreset as aH, type PriceSource as aI, type OhlcLabels as aa, type OrderSubmit as ab, PRESETS_BY_COUNT as ac, PRESET_COUNTS as ad, PRESET_LABEL as ae, type Padding as af, type PendingOrderLevel as ag, type PositionLevel as ah, type PositionRenderStyle as ai, type PriceAxisUiConfig as aj, RSI as ak, SMA as al, type Theme as am, type ThemeOverrides as an, type TimeAxisUiConfig as ao, type TopBarColors as ap, type TopBarLabels as aq, type TopBarUiConfig as ar, type TradeButtonUiConfig as as, type TradeDisplayFilter as at, type TradeLabels as au, type TradeLevel as av, type TradeLevelColors as aw, type TradePanelColors as ax, type UiConfig as ay, deepMergeTheme as az, type ChartEventMap as b, type ChartState as c, type IDrawing as d, type IWebSocketAdapter as e, type TradeLevelType as f, type ChartTheme as g, type AnyLevel as h, type DrawingPoint as i, ScaleManager as j, type DrawingHandle as k, type SerializedDrawing as l, type Tick as m, type StreamStatus as n, type ActiveIndicatorState as o, type BottomBarColors as p, type BottomBarLabels as q, type BottomBarUiConfig as r, type CanvasColorSettings as s, type ChartLabels as t, type ChartMiscLabels as u, type ChartThemeUi as v, type CrosshairPosition as w, type CrosshairUiConfig as x, DARK_THEME as y, DEFAULT_BOTTOM_BAR_CONFIG as z };
1948
+ export { type DrawingToolbarLabels as $, type AnyDrawingStyle as A, BollingerBands as B, type ChartConfig as C, type Duration as D, DEFAULT_BOTTOM_BAR_CONFIG as E, DEFAULT_CROSSHAIR_CONFIG as F, DEFAULT_DRAWING_TOOLBAR_CONFIG as G, DEFAULT_INDICATOR_OVERLAY_CONFIG as H, type IIndicator as I, DEFAULT_LABELS as J, DEFAULT_LAYOUT_SYNC as K, type LayoutSyncState as L, DEFAULT_PRICE_AXIS_CONFIG as M, DEFAULT_TIME_AXIS_CONFIG as N, type OHLCVBar as O, type PriceRange as P, DEFAULT_TOP_BAR_CONFIG as Q, DEFAULT_TRADE_BUTTON_CONFIG as R, type SeriesType as S, type Timeframe as T, DEFAULT_UI_CONFIG as U, type Viewport as V, type DataLoaderParams as W, type DeepPartial$1 as X, type DeepPartialChartTheme as Y, type DialogLabels as Z, type DrawingToolbarColors as _, type IndicatorParams as a, type DrawingToolbarUiConfig as a0, EMA as a1, type IndicatorOverlayColors as a2, type IndicatorOverlayUiConfig as a3, type IndicatorResult as a4, type IndicatorStateEntry as a5, LAYOUT_PRESETS as a6, LIGHT_THEME as a7, type LayoutPreset as a8, MACD as a9, getAllPresets as aA, getCustomPresets as aB, getPreset as aC, registerCustomPreset as aD, resolveCssVarsInTheme as aE, resolveLabels as aF, resolveUiConfig as aG, unregisterCustomPreset as aH, type PriceSource as aI, type OhlcLabels as aa, type OrderSubmit as ab, PRESETS_BY_COUNT as ac, PRESET_COUNTS as ad, PRESET_LABEL as ae, type Padding as af, type PendingOrderLevel as ag, type PositionLevel as ah, type PositionRenderStyle as ai, type PriceAxisUiConfig as aj, RSI as ak, SMA as al, type Theme as am, type ThemeOverrides as an, type TimeAxisUiConfig as ao, type TopBarColors as ap, type TopBarLabels as aq, type TopBarUiConfig as ar, type TradeButtonUiConfig as as, type TradeDisplayFilter as at, type TradeLabels as au, type TradeLevel as av, type TradeLevelColors as aw, type TradePanelColors as ax, type UiConfig as ay, deepMergeTheme as az, type ChartEventMap as b, type ChartState as c, type DrawingToolType as d, type IDrawing as e, type IWebSocketAdapter as f, type TradeLevelType as g, type ChartTheme as h, type AnyLevel as i, type DrawingPoint as j, type DrawingHandle as k, ScaleManager as l, type SerializedDrawing as m, type Tick as n, type StreamStatus as o, type ActiveIndicatorState as p, type BottomBarColors as q, type BottomBarLabels as r, type BottomBarUiConfig as s, type CanvasColorSettings as t, type ChartLabels as u, type ChartMiscLabels as v, type ChartThemeUi as w, type CrosshairPosition as x, type CrosshairUiConfig as y, DARK_THEME as z };
@@ -1001,6 +1001,24 @@ interface ChartConfig {
1001
1001
  * Clamped to `[1, 3]`. Default: `1`.
1002
1002
  */
1003
1003
  tradeLevelButtonScale?: number;
1004
+ /**
1005
+ * What the SL/TP bracket pills show.
1006
+ *
1007
+ * `'price'` (default) renders the bracket price — `SL 4159.00`.
1008
+ * `'amount'` renders the money the position gains or loses if that bracket
1009
+ * is hit — `SL -$290.80` — computed from the level's `lots`, `contractSize`
1010
+ * and `valuePerPoint`. Falls back to the price for any level lacking the
1011
+ * data needed to compute it, so a partial rollout degrades gracefully.
1012
+ * `'priceAndAmount'` keeps the price but puts the currency symbol in front
1013
+ * of it — `SL $1.27859` — and appends the P/L while the bracket is being
1014
+ * dragged: `SL $1.27859 -$29.08`.
1015
+ */
1016
+ bracketLabelMode?: 'price' | 'amount' | 'priceAndAmount';
1017
+ /**
1018
+ * Currency symbol for SL/TP amounts, used when `bracketLabelMode: 'amount'`
1019
+ * and the level does not carry its own `currencySymbol`. Default `'$'`.
1020
+ */
1021
+ currencySymbol?: string;
1004
1022
  /**
1005
1023
  * When `true`, a theme toggle (Dark / Light) is shown in the Settings dialog.
1006
1024
  * Default: `false` — the toggle is hidden.
@@ -1226,6 +1244,15 @@ interface DrawingPoint {
1226
1244
  interface DrawingHandle {
1227
1245
  pointIndex: number;
1228
1246
  cursor: string;
1247
+ /**
1248
+ * Corners that are a mixture of two stored points — a rectangle's top-right
1249
+ * is `(p2.barIndex, p1.price)` — set these instead of relying on
1250
+ * `pointIndex` alone. The drag then writes the x to `points[xPointIndex]`
1251
+ * and the y to `points[yPointIndex]`, which is what makes all four corners
1252
+ * of a two-point shape draggable rather than just the two stored ones.
1253
+ */
1254
+ xPointIndex?: number;
1255
+ yPointIndex?: number;
1229
1256
  }
1230
1257
  /** Base per-instance style fields applicable to every drawing. */
1231
1258
  interface DrawingStyle {
@@ -1748,6 +1775,23 @@ interface PositionLevel {
1748
1775
  takeProfitPrice?: number;
1749
1776
  /** Data object for the TP bracket — returned in TP-related events instead of the parent's `data`. */
1750
1777
  takeProfitData?: unknown;
1778
+ /**
1779
+ * Units per lot for this instrument (e.g. `100` for XAUUSD, `100000` for most
1780
+ * FX pairs). Only used when `bracketLabelMode: 'amount'`, to convert an SL/TP
1781
+ * price distance into money. Default `1`.
1782
+ */
1783
+ contractSize?: number;
1784
+ /**
1785
+ * Account-currency value of one price unit per contract unit — folds in any
1786
+ * quote → account conversion. Only used when `bracketLabelMode: 'amount'`.
1787
+ * Default `1`.
1788
+ */
1789
+ valuePerPoint?: number;
1790
+ /**
1791
+ * Currency symbol for this level's SL/TP amounts. Falls back to
1792
+ * `ChartConfig.currencySymbol`, then `'$'`.
1793
+ */
1794
+ currencySymbol?: string;
1751
1795
  /**
1752
1796
  * When true, the entry price line becomes draggable — renders a grip handle and emits
1753
1797
  * `tradeLevelEdit` with `field: 'main'` on confirm. Use this for pending entry orders
@@ -1901,4 +1945,4 @@ declare class MACD implements IIndicator {
1901
1945
  render(ctx: CanvasRenderingContext2D, results: IndicatorResult[], scale: ScaleManager, viewport: Viewport, paneHeight: number, rangeOverride?: PriceRange): void;
1902
1946
  }
1903
1947
 
1904
- export { type DrawingToolbarUiConfig as $, type AnyDrawingStyle as A, BollingerBands as B, type ChartConfig as C, type DrawingToolType as D, DEFAULT_CROSSHAIR_CONFIG as E, DEFAULT_DRAWING_TOOLBAR_CONFIG as F, DEFAULT_INDICATOR_OVERLAY_CONFIG as G, DEFAULT_LABELS as H, type IIndicator as I, DEFAULT_LAYOUT_SYNC as J, DEFAULT_PRICE_AXIS_CONFIG as K, type LayoutSyncState as L, DEFAULT_TIME_AXIS_CONFIG as M, DEFAULT_TOP_BAR_CONFIG as N, type OHLCVBar as O, type PriceRange as P, DEFAULT_TRADE_BUTTON_CONFIG as Q, DEFAULT_UI_CONFIG as R, type SeriesType as S, type Timeframe as T, type DataLoaderParams as U, type Viewport as V, type DeepPartial$1 as W, type DeepPartialChartTheme as X, type DialogLabels as Y, type DrawingToolbarColors as Z, type DrawingToolbarLabels as _, type IndicatorParams as a, type Duration as a0, EMA as a1, type IndicatorOverlayColors as a2, type IndicatorOverlayUiConfig as a3, type IndicatorResult as a4, type IndicatorStateEntry as a5, LAYOUT_PRESETS as a6, LIGHT_THEME as a7, type LayoutPreset as a8, MACD as a9, getAllPresets as aA, getCustomPresets as aB, getPreset as aC, registerCustomPreset as aD, resolveCssVarsInTheme as aE, resolveLabels as aF, resolveUiConfig as aG, unregisterCustomPreset as aH, type PriceSource as aI, type OhlcLabels as aa, type OrderSubmit as ab, PRESETS_BY_COUNT as ac, PRESET_COUNTS as ad, PRESET_LABEL as ae, type Padding as af, type PendingOrderLevel as ag, type PositionLevel as ah, type PositionRenderStyle as ai, type PriceAxisUiConfig as aj, RSI as ak, SMA as al, type Theme as am, type ThemeOverrides as an, type TimeAxisUiConfig as ao, type TopBarColors as ap, type TopBarLabels as aq, type TopBarUiConfig as ar, type TradeButtonUiConfig as as, type TradeDisplayFilter as at, type TradeLabels as au, type TradeLevel as av, type TradeLevelColors as aw, type TradePanelColors as ax, type UiConfig as ay, deepMergeTheme as az, type ChartEventMap as b, type ChartState as c, type IDrawing as d, type IWebSocketAdapter as e, type TradeLevelType as f, type ChartTheme as g, type AnyLevel as h, type DrawingPoint as i, ScaleManager as j, type DrawingHandle as k, type SerializedDrawing as l, type Tick as m, type StreamStatus as n, type ActiveIndicatorState as o, type BottomBarColors as p, type BottomBarLabels as q, type BottomBarUiConfig as r, type CanvasColorSettings as s, type ChartLabels as t, type ChartMiscLabels as u, type ChartThemeUi as v, type CrosshairPosition as w, type CrosshairUiConfig as x, DARK_THEME as y, DEFAULT_BOTTOM_BAR_CONFIG as z };
1948
+ export { type DrawingToolbarLabels as $, type AnyDrawingStyle as A, BollingerBands as B, type ChartConfig as C, type Duration as D, DEFAULT_BOTTOM_BAR_CONFIG as E, DEFAULT_CROSSHAIR_CONFIG as F, DEFAULT_DRAWING_TOOLBAR_CONFIG as G, DEFAULT_INDICATOR_OVERLAY_CONFIG as H, type IIndicator as I, DEFAULT_LABELS as J, DEFAULT_LAYOUT_SYNC as K, type LayoutSyncState as L, DEFAULT_PRICE_AXIS_CONFIG as M, DEFAULT_TIME_AXIS_CONFIG as N, type OHLCVBar as O, type PriceRange as P, DEFAULT_TOP_BAR_CONFIG as Q, DEFAULT_TRADE_BUTTON_CONFIG as R, type SeriesType as S, type Timeframe as T, DEFAULT_UI_CONFIG as U, type Viewport as V, type DataLoaderParams as W, type DeepPartial$1 as X, type DeepPartialChartTheme as Y, type DialogLabels as Z, type DrawingToolbarColors as _, type IndicatorParams as a, type DrawingToolbarUiConfig as a0, EMA as a1, type IndicatorOverlayColors as a2, type IndicatorOverlayUiConfig as a3, type IndicatorResult as a4, type IndicatorStateEntry as a5, LAYOUT_PRESETS as a6, LIGHT_THEME as a7, type LayoutPreset as a8, MACD as a9, getAllPresets as aA, getCustomPresets as aB, getPreset as aC, registerCustomPreset as aD, resolveCssVarsInTheme as aE, resolveLabels as aF, resolveUiConfig as aG, unregisterCustomPreset as aH, type PriceSource as aI, type OhlcLabels as aa, type OrderSubmit as ab, PRESETS_BY_COUNT as ac, PRESET_COUNTS as ad, PRESET_LABEL as ae, type Padding as af, type PendingOrderLevel as ag, type PositionLevel as ah, type PositionRenderStyle as ai, type PriceAxisUiConfig as aj, RSI as ak, SMA as al, type Theme as am, type ThemeOverrides as an, type TimeAxisUiConfig as ao, type TopBarColors as ap, type TopBarLabels as aq, type TopBarUiConfig as ar, type TradeButtonUiConfig as as, type TradeDisplayFilter as at, type TradeLabels as au, type TradeLevel as av, type TradeLevelColors as aw, type TradePanelColors as ax, type UiConfig as ay, deepMergeTheme as az, type ChartEventMap as b, type ChartState as c, type DrawingToolType as d, type IDrawing as e, type IWebSocketAdapter as f, type TradeLevelType as g, type ChartTheme as h, type AnyLevel as i, type DrawingPoint as j, type DrawingHandle as k, ScaleManager as l, type SerializedDrawing as m, type Tick as n, type StreamStatus as o, type ActiveIndicatorState as p, type BottomBarColors as q, type BottomBarLabels as r, type BottomBarUiConfig as s, type CanvasColorSettings as t, type ChartLabels as u, type ChartMiscLabels as v, type ChartThemeUi as w, type CrosshairPosition as x, type CrosshairUiConfig as y, DARK_THEME as z };