acttrader-charts 1.0.8 → 1.0.10
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 +20 -0
- package/dist/{MACD-CHD5mG7r.d.cts → MACD-D8wk8S7g.d.cts} +13 -9
- package/dist/{MACD-CHD5mG7r.d.ts → MACD-D8wk8S7g.d.ts} +13 -9
- package/dist/{chunk-X6OSI4P2.js → chunk-3H3T5S77.js} +13 -24
- package/dist/chunk-3H3T5S77.js.map +1 -0
- package/dist/index.cjs +394 -299
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -11
- package/dist/index.d.ts +37 -11
- package/dist/index.js +385 -279
- package/dist/index.js.map +1 -1
- package/dist/indicators/index.cjs +11 -22
- package/dist/indicators/index.cjs.map +1 -1
- package/dist/indicators/index.d.cts +2 -2
- package/dist/indicators/index.d.ts +2 -2
- package/dist/indicators/index.js +1 -1
- package/dist/webview/chart.html +67 -67
- package/package.json +1 -1
- package/dist/chunk-X6OSI4P2.js.map +0 -1
package/README.md
CHANGED
|
@@ -194,6 +194,18 @@ chart.on('tradeLevelDrag', ({ label, newPrice, bracketType, isFullscreen }) => {
|
|
|
194
194
|
| `buy` | must stay ≤ order price | must stay ≥ order price |
|
|
195
195
|
| `sell` | must stay ≥ order price | must stay ≤ order price |
|
|
196
196
|
|
|
197
|
+
**Mobile mode — `hideLevelConfirmCancel: true`:**
|
|
198
|
+
|
|
199
|
+
When the on-canvas ✓/✗ buttons are hidden (mobile native UI), the chart adapts its interaction model:
|
|
200
|
+
|
|
201
|
+
- **Tap a trade level line** → `tradeLevelEditOpen` fires immediately (the whole line acts as the edit button; no pencil icon required).
|
|
202
|
+
- **Tap empty canvas area while a level is selected** → edit is dismissed and any pending drag changes are reverted (equivalent to pressing ✗).
|
|
203
|
+
- **Drag a SL/TP bracket and release** → `tradeLevelEdit` fires automatically without needing a ✓ button tap.
|
|
204
|
+
|
|
205
|
+
**Market orders — BID/ASK spread zone:**
|
|
206
|
+
|
|
207
|
+
When `enableTrading` is on and live BID/ASK data is streaming, hovering / activating the trade crosshair button while the cursor price is inside the spread shows **"Buy Market"** and **"Sell Market"** rows instead of the standard Limit/Stop rows. Tapping either row calls `showMarketDraft()` internally and emits `draftInitiated` with `orderType: 'market'`.
|
|
208
|
+
|
|
197
209
|
---
|
|
198
210
|
|
|
199
211
|
## Default Configuration
|
|
@@ -484,6 +496,8 @@ chart.setDrawingTool(tool: DrawingToolType | null): this
|
|
|
484
496
|
chart.setLevels(levels, labelField, priceField, type): this
|
|
485
497
|
chart.removeLevelByLabel(label: string): this
|
|
486
498
|
chart.cancelCurrentEdit(): this // cancel the active draft order or in-progress level edit; no-op when nothing is active
|
|
499
|
+
chart.addLevelBracket(label: string, bracketType: 'sl' | 'tp'): this // auto-place a SL or TP bracket at a default offset; emits tradeLevelBracketActivated with the computed price
|
|
500
|
+
chart.setDraftBracketPnl(bracketType: 'sl' | 'tp', pnlText: string | null): this // set estimated P&L text on a draft order bracket line; pass null to clear
|
|
487
501
|
```
|
|
488
502
|
|
|
489
503
|
### Trade Button
|
|
@@ -662,6 +676,12 @@ chart.on('draftInitiated', ({ side, price, orderType, isFullscreen }) => {})
|
|
|
662
676
|
chart.on('draftCancelled', ({ label, isFullscreen }) => {}); // draft order dismissed without confirming
|
|
663
677
|
chart.on('tradeLevelDragEnd', ({ label, type, newPrice, data }) => {}); // deprecated — use tradeLevelEdit
|
|
664
678
|
chart.on('tradeLevelBracketDrag', ({ label, bracketType, newPrice, data }) => {}); // deprecated
|
|
679
|
+
|
|
680
|
+
// Fires after addLevelBracket() auto-places a bracket, delivering the computed price back to the caller
|
|
681
|
+
chart.on('tradeLevelBracketActivated', ({ label, bracketType, price, isFullscreen }) => {
|
|
682
|
+
// Use price to pre-populate the SL/TP input field in your native form
|
|
683
|
+
updateBracketPriceInput(bracketType, price);
|
|
684
|
+
});
|
|
665
685
|
```
|
|
666
686
|
|
|
667
687
|
---
|
|
@@ -488,7 +488,7 @@ interface PriceRange {
|
|
|
488
488
|
}
|
|
489
489
|
type SeriesType = "candlestick" | "hollow" | "line" | "area" | "ohlc" | "heikinashi" | "volumecandles" | "linemarkers" | "step" | "hlcarea" | "baseline" | "columns" | "highlow";
|
|
490
490
|
type Theme = "dark" | "light";
|
|
491
|
-
type Timeframe = "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "
|
|
491
|
+
type Timeframe = "1m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "8h" | "1D" | "1W" | "1M";
|
|
492
492
|
type Duration = "1D" | "5D" | "1M" | "3M" | "6M" | "1Y" | "5Y" | "All";
|
|
493
493
|
interface Padding {
|
|
494
494
|
top: number;
|
|
@@ -518,6 +518,8 @@ interface ChartConfig {
|
|
|
518
518
|
showUI?: boolean;
|
|
519
519
|
/** If false, the drawing tools toolbar and pencil button are hidden entirely. Default: true */
|
|
520
520
|
showDrawingTools?: boolean;
|
|
521
|
+
/** If false, the settings gear button in the top bar is hidden entirely. Default: true */
|
|
522
|
+
showSettings?: boolean;
|
|
521
523
|
timeframe?: Timeframe;
|
|
522
524
|
duration?: Duration;
|
|
523
525
|
symbol?: string;
|
|
@@ -532,12 +534,8 @@ interface ChartConfig {
|
|
|
532
534
|
*/
|
|
533
535
|
onSymbolClick?: (symbol: string) => void;
|
|
534
536
|
padding?: Partial<Padding>;
|
|
535
|
-
/** Minimum (and default) lot size shown in the trade popover and pre-filled in the draft order qty input (default: 1) */
|
|
536
|
-
minLots?: number;
|
|
537
537
|
/** Called when user submits an order via the floating trade button */
|
|
538
538
|
onOrderSubmit?: (order: OrderSubmit) => void;
|
|
539
|
-
/** Called when the user changes the qty input on a draft order. Use to sync external order panels. */
|
|
540
|
-
onLotsChange?: (lots: number) => void;
|
|
541
539
|
/** @deprecated Use onLevelEdit which delivers all changes in one event. */
|
|
542
540
|
onLevelDragEnd?: (payload: {
|
|
543
541
|
label: string;
|
|
@@ -740,11 +738,10 @@ interface ChartConfig {
|
|
|
740
738
|
*/
|
|
741
739
|
hideLevelConfirmCancel?: boolean;
|
|
742
740
|
/**
|
|
743
|
-
*
|
|
744
|
-
*
|
|
745
|
-
* Default: `false`.
|
|
741
|
+
* When `true`, a theme toggle (Dark / Light) is shown in the Settings dialog.
|
|
742
|
+
* Default: `false` — the toggle is hidden.
|
|
746
743
|
*/
|
|
747
|
-
|
|
744
|
+
enableThemeToggle?: boolean;
|
|
748
745
|
}
|
|
749
746
|
interface IndicatorResult {
|
|
750
747
|
index: number;
|
|
@@ -986,6 +983,13 @@ type ChartEventMap = {
|
|
|
986
983
|
openingBar: OHLCVBar;
|
|
987
984
|
intervalMs: number;
|
|
988
985
|
};
|
|
986
|
+
/** Emitted after addLevelBracket() / addBracket() auto-places a SL or TP bracket so consumers can populate their form's price field. label is an empty string when the bracket was placed on a draft order (no external ID yet). */
|
|
987
|
+
tradeLevelBracketActivated: {
|
|
988
|
+
label: string;
|
|
989
|
+
bracketType: 'sl' | 'tp';
|
|
990
|
+
price: number;
|
|
991
|
+
isFullscreen: boolean;
|
|
992
|
+
};
|
|
989
993
|
/** Emitted when the user confirms all edits to a level — replaces separate tradeLevelDragEnd / tradeLevelBracketDrag events. */
|
|
990
994
|
tradeLevelEdit: {
|
|
991
995
|
label: string;
|
|
@@ -488,7 +488,7 @@ interface PriceRange {
|
|
|
488
488
|
}
|
|
489
489
|
type SeriesType = "candlestick" | "hollow" | "line" | "area" | "ohlc" | "heikinashi" | "volumecandles" | "linemarkers" | "step" | "hlcarea" | "baseline" | "columns" | "highlow";
|
|
490
490
|
type Theme = "dark" | "light";
|
|
491
|
-
type Timeframe = "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "
|
|
491
|
+
type Timeframe = "1m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "8h" | "1D" | "1W" | "1M";
|
|
492
492
|
type Duration = "1D" | "5D" | "1M" | "3M" | "6M" | "1Y" | "5Y" | "All";
|
|
493
493
|
interface Padding {
|
|
494
494
|
top: number;
|
|
@@ -518,6 +518,8 @@ interface ChartConfig {
|
|
|
518
518
|
showUI?: boolean;
|
|
519
519
|
/** If false, the drawing tools toolbar and pencil button are hidden entirely. Default: true */
|
|
520
520
|
showDrawingTools?: boolean;
|
|
521
|
+
/** If false, the settings gear button in the top bar is hidden entirely. Default: true */
|
|
522
|
+
showSettings?: boolean;
|
|
521
523
|
timeframe?: Timeframe;
|
|
522
524
|
duration?: Duration;
|
|
523
525
|
symbol?: string;
|
|
@@ -532,12 +534,8 @@ interface ChartConfig {
|
|
|
532
534
|
*/
|
|
533
535
|
onSymbolClick?: (symbol: string) => void;
|
|
534
536
|
padding?: Partial<Padding>;
|
|
535
|
-
/** Minimum (and default) lot size shown in the trade popover and pre-filled in the draft order qty input (default: 1) */
|
|
536
|
-
minLots?: number;
|
|
537
537
|
/** Called when user submits an order via the floating trade button */
|
|
538
538
|
onOrderSubmit?: (order: OrderSubmit) => void;
|
|
539
|
-
/** Called when the user changes the qty input on a draft order. Use to sync external order panels. */
|
|
540
|
-
onLotsChange?: (lots: number) => void;
|
|
541
539
|
/** @deprecated Use onLevelEdit which delivers all changes in one event. */
|
|
542
540
|
onLevelDragEnd?: (payload: {
|
|
543
541
|
label: string;
|
|
@@ -740,11 +738,10 @@ interface ChartConfig {
|
|
|
740
738
|
*/
|
|
741
739
|
hideLevelConfirmCancel?: boolean;
|
|
742
740
|
/**
|
|
743
|
-
*
|
|
744
|
-
*
|
|
745
|
-
* Default: `false`.
|
|
741
|
+
* When `true`, a theme toggle (Dark / Light) is shown in the Settings dialog.
|
|
742
|
+
* Default: `false` — the toggle is hidden.
|
|
746
743
|
*/
|
|
747
|
-
|
|
744
|
+
enableThemeToggle?: boolean;
|
|
748
745
|
}
|
|
749
746
|
interface IndicatorResult {
|
|
750
747
|
index: number;
|
|
@@ -986,6 +983,13 @@ type ChartEventMap = {
|
|
|
986
983
|
openingBar: OHLCVBar;
|
|
987
984
|
intervalMs: number;
|
|
988
985
|
};
|
|
986
|
+
/** Emitted after addLevelBracket() / addBracket() auto-places a SL or TP bracket so consumers can populate their form's price field. label is an empty string when the bracket was placed on a draft order (no external ID yet). */
|
|
987
|
+
tradeLevelBracketActivated: {
|
|
988
|
+
label: string;
|
|
989
|
+
bracketType: 'sl' | 'tp';
|
|
990
|
+
price: number;
|
|
991
|
+
isFullscreen: boolean;
|
|
992
|
+
};
|
|
989
993
|
/** Emitted when the user confirms all edits to a level — replaces separate tradeLevelDragEnd / tradeLevelBracketDrag events. */
|
|
990
994
|
tradeLevelEdit: {
|
|
991
995
|
label: string;
|
|
@@ -374,32 +374,21 @@ var KeltnerChannels = class {
|
|
|
374
374
|
Math.abs(bar.low - data[i - 1].close)
|
|
375
375
|
);
|
|
376
376
|
if (atr === null) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
Math.abs(b.high - prev.close),
|
|
388
|
-
Math.abs(b.low - prev.close)
|
|
389
|
-
);
|
|
390
|
-
trSum += trj;
|
|
391
|
-
}
|
|
392
|
-
atr = trSum / this.atrPeriod;
|
|
393
|
-
}
|
|
394
|
-
continue;
|
|
377
|
+
let trSum = 0;
|
|
378
|
+
for (let j = 0; j < this.atrPeriod; j++) {
|
|
379
|
+
const b = data[i - j];
|
|
380
|
+
const prev = i - j > 0 ? data[i - j - 1] : null;
|
|
381
|
+
const trj = prev == null ? b.high - b.low : Math.max(
|
|
382
|
+
b.high - b.low,
|
|
383
|
+
Math.abs(b.high - prev.close),
|
|
384
|
+
Math.abs(b.low - prev.close)
|
|
385
|
+
);
|
|
386
|
+
trSum += trj;
|
|
395
387
|
}
|
|
388
|
+
atr = trSum / this.atrPeriod;
|
|
396
389
|
} else {
|
|
397
390
|
atr = (atr * (this.atrPeriod - 1) + tr) / this.atrPeriod;
|
|
398
391
|
}
|
|
399
|
-
if (atr === null) {
|
|
400
|
-
results.push({ index: i, value: null, upper: null, lower: null });
|
|
401
|
-
continue;
|
|
402
|
-
}
|
|
403
392
|
const upper = ema + this.mult * atr;
|
|
404
393
|
const lower = ema - this.mult * atr;
|
|
405
394
|
results.push({ index: i, value: ema, upper, lower });
|
|
@@ -2519,5 +2508,5 @@ var LinearRegression = class {
|
|
|
2519
2508
|
};
|
|
2520
2509
|
|
|
2521
2510
|
export { ADX, ATR, AccDistribution, AwesomeOscillator, BollingerBands, CCI, CMF, DonchianChannels, EMA, FibRetracementIndicator, HMA, HeikinAshi, IchimokuCloud, KeltnerChannels, LinearRegression, MACD, MARibbon, MFI, OBV, ParabolicSAR, PivotPoints, ROC, RSI, SMA, StochRSI, Stochastic, Supertrend, VOL, VWAP, WMA, WilliamsR };
|
|
2522
|
-
//# sourceMappingURL=chunk-
|
|
2523
|
-
//# sourceMappingURL=chunk-
|
|
2511
|
+
//# sourceMappingURL=chunk-3H3T5S77.js.map
|
|
2512
|
+
//# sourceMappingURL=chunk-3H3T5S77.js.map
|