oakscriptjs 0.9.6 → 0.10.1
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 +1 -1
- package/dist/cjs/array/index.d.ts +9 -23
- package/dist/cjs/array/index.d.ts.map +1 -1
- package/dist/cjs/array/index.js +4 -0
- package/dist/cjs/array/index.js.map +2 -2
- package/dist/cjs/drawing/bar-time.d.ts +24 -0
- package/dist/cjs/drawing/bar-time.d.ts.map +1 -0
- package/dist/cjs/drawing/bar-time.js +47 -0
- package/dist/cjs/drawing/bar-time.js.map +7 -0
- package/dist/cjs/drawing/output.d.ts +32 -0
- package/dist/cjs/drawing/output.d.ts.map +1 -0
- package/dist/cjs/drawing/output.js +184 -0
- package/dist/cjs/drawing/output.js.map +7 -0
- package/dist/cjs/drawing/registry.d.ts +5 -4
- package/dist/cjs/drawing/registry.d.ts.map +1 -1
- package/dist/cjs/drawing/registry.js +11 -2
- package/dist/cjs/drawing/registry.js.map +2 -2
- package/dist/cjs/index.d.ts +7 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +11 -2
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/polyline/index.d.ts +3 -5
- package/dist/cjs/polyline/index.d.ts.map +1 -1
- package/dist/cjs/polyline/index.js +0 -5
- package/dist/cjs/polyline/index.js.map +2 -2
- package/dist/cjs/runtime/index.d.ts +2 -1
- package/dist/cjs/runtime/index.d.ts.map +1 -1
- package/dist/cjs/runtime/index.js +2 -0
- package/dist/cjs/runtime/index.js.map +2 -2
- package/dist/cjs/runtime/input-active.d.ts +27 -0
- package/dist/cjs/runtime/input-active.d.ts.map +1 -0
- package/dist/cjs/runtime/input-active.js +44 -0
- package/dist/cjs/runtime/input-active.js.map +7 -0
- package/dist/cjs/runtime/types.d.ts +51 -2
- package/dist/cjs/runtime/types.d.ts.map +1 -1
- package/dist/cjs/runtime/types.js.map +1 -1
- package/dist/cjs/script/index.d.ts +104 -8
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +163 -28
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/str/index.d.ts +9 -3
- package/dist/cjs/str/index.d.ts.map +1 -1
- package/dist/cjs/str/index.js +11 -6
- package/dist/cjs/str/index.js.map +2 -2
- package/dist/cjs/str/numberformat.d.ts +6 -0
- package/dist/cjs/str/numberformat.d.ts.map +1 -1
- package/dist/cjs/str/numberformat.js +9 -1
- package/dist/cjs/str/numberformat.js.map +2 -2
- package/dist/cjs/table/index.d.ts +87 -0
- package/dist/cjs/table/index.d.ts.map +1 -0
- package/dist/cjs/table/index.js +150 -0
- package/dist/cjs/table/index.js.map +7 -0
- package/dist/cjs/text/index.d.ts +17 -2
- package/dist/cjs/text/index.d.ts.map +1 -1
- package/dist/cjs/text/index.js +15 -1
- package/dist/cjs/text/index.js.map +2 -2
- package/dist/cjs/types/index.d.ts +30 -1
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +12 -0
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/cjs/types/metadata.d.ts +258 -26
- package/dist/cjs/types/metadata.d.ts.map +1 -1
- package/dist/cjs/types/metadata.js.map +1 -1
- package/dist/esm/array/index.d.ts +9 -23
- package/dist/esm/array/index.d.ts.map +1 -1
- package/dist/esm/array/index.js +10 -22
- package/dist/esm/array/index.js.map +1 -1
- package/dist/esm/drawing/bar-time.d.ts +24 -0
- package/dist/esm/drawing/bar-time.d.ts.map +1 -0
- package/dist/esm/drawing/bar-time.js +44 -0
- package/dist/esm/drawing/bar-time.js.map +1 -0
- package/dist/esm/drawing/output.d.ts +32 -0
- package/dist/esm/drawing/output.d.ts.map +1 -0
- package/dist/esm/drawing/output.js +190 -0
- package/dist/esm/drawing/output.js.map +1 -0
- package/dist/esm/drawing/registry.d.ts +5 -4
- package/dist/esm/drawing/registry.d.ts.map +1 -1
- package/dist/esm/drawing/registry.js +12 -2
- package/dist/esm/drawing/registry.js.map +1 -1
- package/dist/esm/index.d.ts +7 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/polyline/index.d.ts +3 -5
- package/dist/esm/polyline/index.d.ts.map +1 -1
- package/dist/esm/polyline/index.js +3 -9
- package/dist/esm/polyline/index.js.map +1 -1
- package/dist/esm/runtime/index.d.ts +2 -1
- package/dist/esm/runtime/index.d.ts.map +1 -1
- package/dist/esm/runtime/index.js +1 -0
- package/dist/esm/runtime/index.js.map +1 -1
- package/dist/esm/runtime/input-active.d.ts +27 -0
- package/dist/esm/runtime/input-active.d.ts.map +1 -0
- package/dist/esm/runtime/input-active.js +54 -0
- package/dist/esm/runtime/input-active.js.map +1 -0
- package/dist/esm/runtime/types.d.ts +51 -2
- package/dist/esm/runtime/types.d.ts.map +1 -1
- package/dist/esm/script/index.d.ts +104 -8
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +194 -24
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/str/index.d.ts +9 -3
- package/dist/esm/str/index.d.ts.map +1 -1
- package/dist/esm/str/index.js +25 -10
- package/dist/esm/str/index.js.map +1 -1
- package/dist/esm/str/numberformat.d.ts +6 -0
- package/dist/esm/str/numberformat.d.ts.map +1 -1
- package/dist/esm/str/numberformat.js +12 -0
- package/dist/esm/str/numberformat.js.map +1 -1
- package/dist/esm/table/index.d.ts +87 -0
- package/dist/esm/table/index.d.ts.map +1 -0
- package/dist/esm/table/index.js +169 -0
- package/dist/esm/table/index.js.map +1 -0
- package/dist/esm/text/index.d.ts +17 -2
- package/dist/esm/text/index.d.ts.map +1 -1
- package/dist/esm/text/index.js +17 -2
- package/dist/esm/text/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +30 -1
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +14 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/metadata.d.ts +258 -26
- package/dist/esm/types/metadata.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/array/index.ts +12 -23
- package/src/drawing/bar-time.ts +42 -0
- package/src/drawing/output.ts +214 -0
- package/src/drawing/registry.ts +16 -6
- package/src/index.ts +11 -3
- package/src/polyline/index.ts +3 -12
- package/src/runtime/index.ts +3 -0
- package/src/runtime/input-active.ts +50 -0
- package/src/runtime/types.ts +48 -2
- package/src/script/index.ts +301 -30
- package/src/str/index.ts +23 -10
- package/src/str/numberformat.ts +13 -0
- package/src/table/index.ts +221 -0
- package/src/text/index.ts +18 -2
- package/src/types/index.ts +32 -1
- package/src/types/metadata.ts +325 -26
package/dist/cjs/script/index.js
CHANGED
|
@@ -56,6 +56,7 @@ __export(script_exports, {
|
|
|
56
56
|
inSession: () => inSession,
|
|
57
57
|
indicator: () => indicator,
|
|
58
58
|
input: () => input,
|
|
59
|
+
isInputActive: () => import_input_active.isInputActive,
|
|
59
60
|
label: () => label,
|
|
60
61
|
line: () => line,
|
|
61
62
|
linefill: () => linefill,
|
|
@@ -69,9 +70,12 @@ __export(script_exports, {
|
|
|
69
70
|
open: () => open,
|
|
70
71
|
plot: () => plot,
|
|
71
72
|
plotarrow: () => plotarrow,
|
|
73
|
+
plotbar: () => plotbar,
|
|
74
|
+
plotcandle: () => plotcandle,
|
|
72
75
|
plotchar: () => plotchar,
|
|
73
76
|
plotshape: () => plotshape,
|
|
74
77
|
polyline: () => polyline,
|
|
78
|
+
position: () => import_types.position,
|
|
75
79
|
request: () => request,
|
|
76
80
|
second: () => second,
|
|
77
81
|
seriesOf: () => seriesOf,
|
|
@@ -80,6 +84,7 @@ __export(script_exports, {
|
|
|
80
84
|
strategy: () => strategy,
|
|
81
85
|
syminfo: () => syminfo,
|
|
82
86
|
ta: () => ta,
|
|
87
|
+
table: () => table,
|
|
83
88
|
text: () => text,
|
|
84
89
|
ticker: () => ticker,
|
|
85
90
|
time: () => time,
|
|
@@ -102,21 +107,26 @@ var labelCore = __toESM(require("../label/index.js"), 1);
|
|
|
102
107
|
var boxCore = __toESM(require("../box/index.js"), 1);
|
|
103
108
|
var linefillCore = __toESM(require("../linefill/index.js"), 1);
|
|
104
109
|
var polylineCore = __toESM(require("../polyline/index.js"), 1);
|
|
110
|
+
var tableCore = __toESM(require("../table/index.js"), 1);
|
|
105
111
|
var chartPointCore = __toESM(require("../chartpoint/index.js"), 1);
|
|
106
112
|
var textCore = __toESM(require("../text/index.js"), 1);
|
|
107
113
|
var mathCore = __toESM(require("../math/index.js"), 1);
|
|
108
114
|
var import_registry = require("../drawing/registry.js");
|
|
115
|
+
var import_output = require("../drawing/output.js");
|
|
109
116
|
var timeframeCore = __toESM(require("../timeframe/index.js"), 1);
|
|
110
117
|
var timeCore = __toESM(require("../time/index.js"), 1);
|
|
111
118
|
var strCore = __toESM(require("../str/index.js"), 1);
|
|
112
119
|
var import_messageformat = require("../str/messageformat.js");
|
|
120
|
+
var import_numberformat = require("../str/numberformat.js");
|
|
113
121
|
var import_calendar = require("../session/calendar.js");
|
|
114
122
|
var import_bars = require("../session/bars.js");
|
|
115
123
|
var import_resample = require("../security/resample.js");
|
|
124
|
+
var import_types = require("../types/index.js");
|
|
116
125
|
var import_strategy = require("../strategy/index.js");
|
|
117
126
|
var import_session = require("../time/session.js");
|
|
118
127
|
var import_strategy2 = require("../strategy/index.js");
|
|
119
128
|
var compare = __toESM(require("../compare/index.js"), 1);
|
|
129
|
+
var import_input_active = require("../runtime/input-active.js");
|
|
120
130
|
const ctxBars = new import_series.BarData([]);
|
|
121
131
|
let ctx = null;
|
|
122
132
|
function collector() {
|
|
@@ -145,8 +155,11 @@ function freshCollector(inputValues) {
|
|
|
145
155
|
arrowConfig: [],
|
|
146
156
|
arrows: [],
|
|
147
157
|
barColorConfig: [],
|
|
148
|
-
|
|
149
|
-
|
|
158
|
+
bgColors: [],
|
|
159
|
+
barColors: [],
|
|
160
|
+
candleConfig: [],
|
|
161
|
+
plotCandles: {},
|
|
162
|
+
plotBars: {},
|
|
150
163
|
alertConfig: [],
|
|
151
164
|
alerts: []
|
|
152
165
|
};
|
|
@@ -184,6 +197,7 @@ function executeScript(body, barsInput, inputs = {}, chart2 = {}, options = {})
|
|
|
184
197
|
shapeConfig: c.shapeConfig,
|
|
185
198
|
arrowConfig: c.arrowConfig,
|
|
186
199
|
barColorConfig: c.barColorConfig,
|
|
200
|
+
candleConfig: c.candleConfig,
|
|
187
201
|
defaultInputs: c.defaultInputs,
|
|
188
202
|
alertConfig: c.alertConfig,
|
|
189
203
|
strategyConfig: c.strategy?.properties,
|
|
@@ -193,8 +207,11 @@ function executeScript(body, barsInput, inputs = {}, chart2 = {}, options = {})
|
|
|
193
207
|
fills: c.fills.length ? c.fills : void 0,
|
|
194
208
|
markers: c.markers.length ? c.markers : void 0,
|
|
195
209
|
arrows: c.arrows.length ? c.arrows : void 0,
|
|
196
|
-
|
|
197
|
-
|
|
210
|
+
bgColors: c.bgColors.length ? c.bgColors : void 0,
|
|
211
|
+
barColors: c.barColors.length ? c.barColors : void 0,
|
|
212
|
+
plotCandles: Object.keys(c.plotCandles).length ? c.plotCandles : void 0,
|
|
213
|
+
plotBars: Object.keys(c.plotBars).length ? c.plotBars : void 0,
|
|
214
|
+
...(0, import_output.drawingOutputs)(ctxBars.bars, chartCtx.timeUnit),
|
|
198
215
|
alerts: c.alerts.length ? c.alerts : void 0
|
|
199
216
|
}
|
|
200
217
|
};
|
|
@@ -230,6 +247,7 @@ function common(opts) {
|
|
|
230
247
|
if (opts.tooltip !== void 0) out.tooltip = opts.tooltip;
|
|
231
248
|
if (opts.confirm !== void 0) out.confirm = opts.confirm;
|
|
232
249
|
if (opts.display !== void 0) out.display = opts.display;
|
|
250
|
+
if (opts.active !== void 0) out.active = opts.active;
|
|
233
251
|
return out;
|
|
234
252
|
}
|
|
235
253
|
function registerInput(config, fallbackId) {
|
|
@@ -375,11 +393,11 @@ function plotImpl(series, title, options = {}) {
|
|
|
375
393
|
const c = collector();
|
|
376
394
|
const id = `plot${c.plotConfig.length}`;
|
|
377
395
|
const perBar2 = Array.isArray(options.color) ? options.color : void 0;
|
|
378
|
-
const
|
|
396
|
+
const staticColor2 = typeof options.color === "string" ? options.color : perBar2?.[perBar2.length - 1] ?? "#2962FF";
|
|
379
397
|
c.plotConfig.push({
|
|
380
398
|
id,
|
|
381
399
|
title: title ?? id,
|
|
382
|
-
color:
|
|
400
|
+
color: staticColor2,
|
|
383
401
|
lineWidth: options.linewidth,
|
|
384
402
|
style: options.style,
|
|
385
403
|
linestyle: options.linestyle,
|
|
@@ -443,7 +461,7 @@ function fill(a, b, ...args) {
|
|
|
443
461
|
const c = collector();
|
|
444
462
|
const third = args[0];
|
|
445
463
|
let perBar2;
|
|
446
|
-
let
|
|
464
|
+
let staticColor2;
|
|
447
465
|
let title;
|
|
448
466
|
let gradient;
|
|
449
467
|
if (typeof third === "number" || third instanceof import_series.Series) {
|
|
@@ -458,12 +476,12 @@ function fill(a, b, ...args) {
|
|
|
458
476
|
} else if (third !== null && typeof third === "object" && !Array.isArray(third)) {
|
|
459
477
|
const options = third;
|
|
460
478
|
perBar2 = Array.isArray(options.color) ? options.color : void 0;
|
|
461
|
-
|
|
479
|
+
staticColor2 = typeof options.color === "string" ? options.color : void 0;
|
|
462
480
|
title = options.title;
|
|
463
481
|
} else {
|
|
464
482
|
const color2 = third;
|
|
465
483
|
perBar2 = Array.isArray(color2) ? color2.map((x) => x ?? "") : void 0;
|
|
466
|
-
|
|
484
|
+
staticColor2 = typeof color2 === "string" ? color2 : void 0;
|
|
467
485
|
title = args[1];
|
|
468
486
|
}
|
|
469
487
|
if (a.kind === "hline" && b.kind === "hline") {
|
|
@@ -471,7 +489,7 @@ function fill(a, b, ...args) {
|
|
|
471
489
|
id: `fill${c.fillConfig.length}`,
|
|
472
490
|
plot1: a.id,
|
|
473
491
|
plot2: b.id,
|
|
474
|
-
color:
|
|
492
|
+
color: staticColor2,
|
|
475
493
|
colors: perBar2,
|
|
476
494
|
gradient,
|
|
477
495
|
title
|
|
@@ -481,11 +499,40 @@ function fill(a, b, ...args) {
|
|
|
481
499
|
c.fills.push({
|
|
482
500
|
plot1: a.id,
|
|
483
501
|
plot2: b.id,
|
|
484
|
-
options: { color:
|
|
502
|
+
options: { color: staticColor2, title },
|
|
485
503
|
colors: perBar2,
|
|
486
504
|
gradient
|
|
487
505
|
});
|
|
488
506
|
}
|
|
507
|
+
const MARKER_SHAPES = {
|
|
508
|
+
xcross: "xcross",
|
|
509
|
+
cross: "cross",
|
|
510
|
+
triangleup: "triangleUp",
|
|
511
|
+
triangledown: "triangleDown",
|
|
512
|
+
flag: "flag",
|
|
513
|
+
circle: "circle",
|
|
514
|
+
arrowup: "arrowUp",
|
|
515
|
+
arrowdown: "arrowDown",
|
|
516
|
+
labelup: "labelUp",
|
|
517
|
+
labeldown: "labelDown",
|
|
518
|
+
square: "square",
|
|
519
|
+
diamond: "diamond"
|
|
520
|
+
};
|
|
521
|
+
function markerPosition(location, shape) {
|
|
522
|
+
switch (location) {
|
|
523
|
+
case "abovebar":
|
|
524
|
+
return "aboveBar";
|
|
525
|
+
case "belowbar":
|
|
526
|
+
return "belowBar";
|
|
527
|
+
case "top":
|
|
528
|
+
return "top";
|
|
529
|
+
case "bottom":
|
|
530
|
+
return "bottom";
|
|
531
|
+
case "absolute":
|
|
532
|
+
return shape === "labeldown" ? "atPriceTop" : shape === "labelup" ? "atPriceBottom" : "atPriceMiddle";
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
const MARKER_COLOR = "#2962FF";
|
|
489
536
|
function emitMarkers(kind, condition, title, options) {
|
|
490
537
|
const c = collector();
|
|
491
538
|
const id = `${kind}${c.shapeConfig.filter((s) => s.kind === kind).length}`;
|
|
@@ -506,6 +553,19 @@ function emitMarkers(kind, condition, title, options) {
|
|
|
506
553
|
offset: options.offset,
|
|
507
554
|
forceOverlay: options.force_overlay
|
|
508
555
|
});
|
|
556
|
+
const shapeStyle = kind === "shape" ? style : void 0;
|
|
557
|
+
const template = {
|
|
558
|
+
position: markerPosition(location, shapeStyle),
|
|
559
|
+
shape: shapeStyle ? MARKER_SHAPES[shapeStyle] : "circle",
|
|
560
|
+
color: options.color ?? MARKER_COLOR,
|
|
561
|
+
id
|
|
562
|
+
};
|
|
563
|
+
if (char !== void 0) template.char = char;
|
|
564
|
+
if (options.text !== void 0) template.text = options.text;
|
|
565
|
+
if (options.textcolor !== void 0) template.textColor = options.textcolor;
|
|
566
|
+
if (options.size !== void 0) template.size = options.size;
|
|
567
|
+
if (options.tooltip !== void 0) template.tooltip = options.tooltip;
|
|
568
|
+
if (options.force_overlay) template.forceOverlay = true;
|
|
509
569
|
const values = condition.toArray();
|
|
510
570
|
const b = bars();
|
|
511
571
|
const off = options.offset ?? 0;
|
|
@@ -514,19 +574,8 @@ function emitMarkers(kind, condition, title, options) {
|
|
|
514
574
|
if (v === void 0 || Number.isNaN(v) || v === 0) continue;
|
|
515
575
|
const j = i + off;
|
|
516
576
|
if (j < 0 || j >= b.length) continue;
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
id,
|
|
520
|
-
location,
|
|
521
|
-
style,
|
|
522
|
-
char,
|
|
523
|
-
color: options.color,
|
|
524
|
-
text: options.text,
|
|
525
|
-
textcolor: options.textcolor,
|
|
526
|
-
size: options.size,
|
|
527
|
-
tooltip: options.tooltip,
|
|
528
|
-
price: location === "absolute" ? v : void 0
|
|
529
|
-
});
|
|
577
|
+
const time2 = b[j].time;
|
|
578
|
+
c.markers.push(location === "absolute" ? { time: time2, ...template, price: v } : { time: time2, ...template });
|
|
530
579
|
}
|
|
531
580
|
}
|
|
532
581
|
function plotshape(condition, title, options = {}) {
|
|
@@ -571,13 +620,14 @@ function emitBarColors(kind, colors, options) {
|
|
|
571
620
|
c.barColorConfig.push({ id, kind, title: options.title, offset: options.offset, forceOverlay: options.force_overlay });
|
|
572
621
|
const b = bars();
|
|
573
622
|
const off = options.offset ?? 0;
|
|
574
|
-
const target = kind === "bgcolor" ? c.
|
|
623
|
+
const target = kind === "bgcolor" ? c.bgColors : c.barColors;
|
|
624
|
+
const forceOverlay = kind === "bgcolor" && options.force_overlay === true;
|
|
575
625
|
for (let i = 0; i < b.length; i++) {
|
|
576
626
|
const col = typeof colors === "string" ? colors : colors[i];
|
|
577
627
|
if (!col) continue;
|
|
578
628
|
const j = i + off;
|
|
579
629
|
if (j < 0 || j >= b.length) continue;
|
|
580
|
-
target.push({ time: b[j].time, color: col });
|
|
630
|
+
target.push(forceOverlay ? { time: b[j].time, color: col, forceOverlay } : { time: b[j].time, color: col });
|
|
581
631
|
}
|
|
582
632
|
}
|
|
583
633
|
function bgcolor(colors, options = {}) {
|
|
@@ -586,6 +636,69 @@ function bgcolor(colors, options = {}) {
|
|
|
586
636
|
function barcolor(colors, options = {}) {
|
|
587
637
|
emitBarColors("barcolor", colors, options);
|
|
588
638
|
}
|
|
639
|
+
function candleColor(col, i) {
|
|
640
|
+
if (col === void 0) return void 0;
|
|
641
|
+
if (typeof col === "string") return col;
|
|
642
|
+
return col[i] ?? "transparent";
|
|
643
|
+
}
|
|
644
|
+
function ohlcRows(o, h, l, cl) {
|
|
645
|
+
const [ov, hv, lv, cv] = [o.toArray(), h.toArray(), l.toArray(), cl.toArray()];
|
|
646
|
+
const rows = [];
|
|
647
|
+
for (let i = 0; i < bars().length; i++) {
|
|
648
|
+
const [open2, high2, low2, close2] = [ov[i], hv[i], lv[i], cv[i]];
|
|
649
|
+
if (Number.isFinite(open2) && Number.isFinite(high2) && Number.isFinite(low2) && Number.isFinite(close2)) {
|
|
650
|
+
rows.push({ i, open: open2, high: high2, low: low2, close: close2 });
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return rows;
|
|
654
|
+
}
|
|
655
|
+
const staticColor = (col) => typeof col === "string" ? col : void 0;
|
|
656
|
+
function plotcandle(open2, high2, low2, close2, title, options = {}) {
|
|
657
|
+
const c = collector();
|
|
658
|
+
const id = `plotcandle${c.candleConfig.filter((x) => x.kind === "candle").length}`;
|
|
659
|
+
c.candleConfig.push({
|
|
660
|
+
id,
|
|
661
|
+
kind: "candle",
|
|
662
|
+
title,
|
|
663
|
+
color: staticColor(options.color),
|
|
664
|
+
wickColor: staticColor(options.wickcolor),
|
|
665
|
+
borderColor: staticColor(options.bordercolor),
|
|
666
|
+
display: options.display,
|
|
667
|
+
forceOverlay: options.force_overlay
|
|
668
|
+
});
|
|
669
|
+
const b = bars();
|
|
670
|
+
c.plotCandles[id] = ohlcRows(open2, high2, low2, close2).map(({ i, ...ohlc }) => {
|
|
671
|
+
const candle = { time: b[i].time, ...ohlc };
|
|
672
|
+
const color2 = candleColor(options.color, i);
|
|
673
|
+
const wickColor = candleColor(options.wickcolor, i);
|
|
674
|
+
const borderColor = candleColor(options.bordercolor, i);
|
|
675
|
+
if (color2 !== void 0) candle.color = color2;
|
|
676
|
+
if (wickColor !== void 0) candle.wickColor = wickColor;
|
|
677
|
+
if (borderColor !== void 0) candle.borderColor = borderColor;
|
|
678
|
+
if (options.force_overlay) candle.forceOverlay = true;
|
|
679
|
+
return candle;
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
function plotbar(open2, high2, low2, close2, title, options = {}) {
|
|
683
|
+
const c = collector();
|
|
684
|
+
const id = `plotbar${c.candleConfig.filter((x) => x.kind === "bar").length}`;
|
|
685
|
+
c.candleConfig.push({
|
|
686
|
+
id,
|
|
687
|
+
kind: "bar",
|
|
688
|
+
title,
|
|
689
|
+
color: staticColor(options.color),
|
|
690
|
+
display: options.display,
|
|
691
|
+
forceOverlay: options.force_overlay
|
|
692
|
+
});
|
|
693
|
+
const b = bars();
|
|
694
|
+
c.plotBars[id] = ohlcRows(open2, high2, low2, close2).map(({ i, ...ohlc }) => {
|
|
695
|
+
const bar = { time: b[i].time, ...ohlc };
|
|
696
|
+
const color2 = candleColor(options.color, i);
|
|
697
|
+
if (color2 !== void 0) bar.color = color2;
|
|
698
|
+
if (options.force_overlay) bar.forceOverlay = true;
|
|
699
|
+
return bar;
|
|
700
|
+
});
|
|
701
|
+
}
|
|
589
702
|
const HISTORY_START = 242;
|
|
590
703
|
const HISTORY_GROWTH = 1.618034;
|
|
591
704
|
function eachBar(fn) {
|
|
@@ -868,14 +981,30 @@ function symbolProperty(key) {
|
|
|
868
981
|
collector();
|
|
869
982
|
const value = chartCtx[key];
|
|
870
983
|
if (value === void 0) {
|
|
984
|
+
if (key === "mintick" && chartCtx.minmove !== void 0 && chartCtx.pricescale !== void 0) {
|
|
985
|
+
return chartCtx.minmove / chartCtx.pricescale;
|
|
986
|
+
}
|
|
871
987
|
throw new Error(`syminfo.${key} is not known: pass it as executeScript(body, bars, inputs, { ${key} }).`);
|
|
872
988
|
}
|
|
873
989
|
return value;
|
|
874
990
|
}
|
|
991
|
+
function symbolScale() {
|
|
992
|
+
collector();
|
|
993
|
+
const { minmove, pricescale } = chartCtx;
|
|
994
|
+
if (minmove !== void 0 && pricescale !== void 0) return [minmove, pricescale];
|
|
995
|
+
const [move, scale] = (0, import_numberformat.tickScale)(symbolProperty("mintick"), pricescale);
|
|
996
|
+
return [minmove ?? move, scale];
|
|
997
|
+
}
|
|
875
998
|
const syminfo = {
|
|
876
999
|
get mintick() {
|
|
877
1000
|
return symbolProperty("mintick");
|
|
878
1001
|
},
|
|
1002
|
+
get minmove() {
|
|
1003
|
+
return symbolScale()[0];
|
|
1004
|
+
},
|
|
1005
|
+
get pricescale() {
|
|
1006
|
+
return symbolScale()[1];
|
|
1007
|
+
},
|
|
879
1008
|
get pointvalue() {
|
|
880
1009
|
return symbolProperty("pointvalue");
|
|
881
1010
|
},
|
|
@@ -925,8 +1054,8 @@ function inSession(time2, session2, timezone) {
|
|
|
925
1054
|
}
|
|
926
1055
|
const str = {
|
|
927
1056
|
...strCore,
|
|
928
|
-
// format.mintick
|
|
929
|
-
tostring: ((value, format, mintick) => strCore.tostring(value, format,
|
|
1057
|
+
// format.mintick uses the chart symbol's tick and price scale (syminfo.mintick, syminfo.pricescale)
|
|
1058
|
+
tostring: ((value, format, mintick, pricescale) => format === "mintick" && mintick === void 0 ? strCore.tostring(value, format, syminfo.mintick, pricescale ?? syminfo.pricescale) : strCore.tostring(value, format, mintick, pricescale)),
|
|
930
1059
|
format_time(time2, format = "yyyy-MM-dd'T'HH:mm:ssZ", timezone) {
|
|
931
1060
|
return strCore.format_time(time2, format, timezone ?? exchangeTimezone());
|
|
932
1061
|
},
|
|
@@ -1171,6 +1300,12 @@ const polyline = {
|
|
|
1171
1300
|
return polylineCore.all();
|
|
1172
1301
|
}
|
|
1173
1302
|
};
|
|
1303
|
+
const table = {
|
|
1304
|
+
...tableCore,
|
|
1305
|
+
get all() {
|
|
1306
|
+
return tableCore.all();
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1174
1309
|
const text = { ...textCore };
|
|
1175
1310
|
const chart = {
|
|
1176
1311
|
point: {
|