lightweight-charts-indicators 0.20.3 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers.d.ts +1 -0
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.mjs +290 -0
- package/dist/index.cjs +295 -9
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +295 -9
- package/dist/live-run.d.ts.map +1 -1
- package/dist/packed-series.d.ts +47 -0
- package/dist/packed-series.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/helpers.d.ts
CHANGED
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
package/dist/helpers.mjs
CHANGED
|
@@ -619,6 +619,286 @@ import {
|
|
|
619
619
|
saveDrawingCheckpoint,
|
|
620
620
|
setDrawingBar
|
|
621
621
|
} from "oakscriptjs";
|
|
622
|
+
|
|
623
|
+
// src/packed-series.ts
|
|
624
|
+
var PACKED = Symbol.for("lightweight-charts-indicators/packed-series");
|
|
625
|
+
function isPoint(p) {
|
|
626
|
+
if (p === null || typeof p !== "object" || Array.isArray(p) || Object.getPrototypeOf(p) !== Object.prototype)
|
|
627
|
+
return false;
|
|
628
|
+
let k = 0;
|
|
629
|
+
for (const f in p) {
|
|
630
|
+
if (k === 0 && f !== "time")
|
|
631
|
+
return false;
|
|
632
|
+
if (k === 1)
|
|
633
|
+
return f === "value" && typeof p.time === "number" && typeof p.value === "number";
|
|
634
|
+
k++;
|
|
635
|
+
}
|
|
636
|
+
return false;
|
|
637
|
+
}
|
|
638
|
+
var Columns = class _Columns {
|
|
639
|
+
/** What the list holds: decided by its first value; `any` keeps them in `items`. */
|
|
640
|
+
kind = "none";
|
|
641
|
+
n = 0;
|
|
642
|
+
time;
|
|
643
|
+
value;
|
|
644
|
+
/** 1 where an entry is set (an index past the others leaves holes). */
|
|
645
|
+
has;
|
|
646
|
+
extra = {};
|
|
647
|
+
items = [];
|
|
648
|
+
constructor(capacity) {
|
|
649
|
+
const cap = Math.max(16, capacity);
|
|
650
|
+
this.time = new Float64Array(cap);
|
|
651
|
+
this.value = new Float64Array(cap);
|
|
652
|
+
this.has = new Uint8Array(cap);
|
|
653
|
+
}
|
|
654
|
+
grow(size) {
|
|
655
|
+
if (size <= this.value.length)
|
|
656
|
+
return;
|
|
657
|
+
const cap = Math.max(size, this.value.length + (this.value.length >> 1));
|
|
658
|
+
const t = new Float64Array(cap);
|
|
659
|
+
t.set(this.time.subarray(0, this.n));
|
|
660
|
+
const v = new Float64Array(cap);
|
|
661
|
+
v.set(this.value.subarray(0, this.n));
|
|
662
|
+
const h = new Uint8Array(cap);
|
|
663
|
+
h.set(this.has.subarray(0, this.n));
|
|
664
|
+
this.time = t;
|
|
665
|
+
this.value = v;
|
|
666
|
+
this.has = h;
|
|
667
|
+
}
|
|
668
|
+
get(i) {
|
|
669
|
+
if (this.kind === "any")
|
|
670
|
+
return this.items[i];
|
|
671
|
+
if (i >= this.n || !this.has[i])
|
|
672
|
+
return void 0;
|
|
673
|
+
if (this.kind === "numbers")
|
|
674
|
+
return this.value[i];
|
|
675
|
+
const p = { time: this.time[i], value: this.value[i] };
|
|
676
|
+
for (const k in this.extra) {
|
|
677
|
+
const x = this.extra[k][i];
|
|
678
|
+
if (x !== void 0)
|
|
679
|
+
p[k] = x;
|
|
680
|
+
}
|
|
681
|
+
return p;
|
|
682
|
+
}
|
|
683
|
+
/** Every entry as it was written, in a plain list (the kinds no longer hold the next value). */
|
|
684
|
+
toAny() {
|
|
685
|
+
const items = new Array(this.n);
|
|
686
|
+
for (let i = 0; i < this.n; i++)
|
|
687
|
+
if (this.has[i])
|
|
688
|
+
items[i] = this.get(i);
|
|
689
|
+
this.kind = "any";
|
|
690
|
+
this.items = items;
|
|
691
|
+
this.time = new Float64Array(0);
|
|
692
|
+
this.value = new Float64Array(0);
|
|
693
|
+
this.has = new Uint8Array(0);
|
|
694
|
+
this.extra = {};
|
|
695
|
+
}
|
|
696
|
+
set(i, p) {
|
|
697
|
+
if (this.kind === "none" && p !== void 0)
|
|
698
|
+
this.kind = isPoint(p) ? "points" : typeof p === "number" ? "numbers" : "any";
|
|
699
|
+
const fits = this.kind === "any" || p === void 0 || (this.kind === "points" ? isPoint(p) : typeof p === "number");
|
|
700
|
+
if (!fits)
|
|
701
|
+
this.toAny();
|
|
702
|
+
if (this.kind === "any") {
|
|
703
|
+
this.items[i] = p;
|
|
704
|
+
if (i >= this.n)
|
|
705
|
+
this.n = i + 1;
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
if (i >= this.n) {
|
|
709
|
+
this.grow(i + 1);
|
|
710
|
+
this.has.fill(0, this.n, i);
|
|
711
|
+
this.n = i + 1;
|
|
712
|
+
}
|
|
713
|
+
this.has[i] = p === void 0 ? 0 : 1;
|
|
714
|
+
for (const k in this.extra) {
|
|
715
|
+
const list = this.extra[k];
|
|
716
|
+
if (i < list.length)
|
|
717
|
+
list[i] = void 0;
|
|
718
|
+
}
|
|
719
|
+
if (p === void 0)
|
|
720
|
+
return;
|
|
721
|
+
if (this.kind === "numbers") {
|
|
722
|
+
this.value[i] = p;
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
const q = p;
|
|
726
|
+
this.time[i] = q.time;
|
|
727
|
+
this.value[i] = q.value;
|
|
728
|
+
for (const k in q) {
|
|
729
|
+
if (k === "time" || k === "value")
|
|
730
|
+
continue;
|
|
731
|
+
const x = q[k];
|
|
732
|
+
if (x !== void 0)
|
|
733
|
+
(this.extra[k] ??= [])[i] = x;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
setLength(len) {
|
|
737
|
+
if (this.kind === "any") {
|
|
738
|
+
this.items.length = len;
|
|
739
|
+
this.n = len;
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
if (len < this.n) {
|
|
743
|
+
for (const k in this.extra) {
|
|
744
|
+
const list = this.extra[k];
|
|
745
|
+
if (list.length > len)
|
|
746
|
+
list.length = len;
|
|
747
|
+
}
|
|
748
|
+
} else if (len > this.n) {
|
|
749
|
+
this.grow(len);
|
|
750
|
+
this.has.fill(0, this.n, len);
|
|
751
|
+
}
|
|
752
|
+
this.n = len;
|
|
753
|
+
}
|
|
754
|
+
/** Entries [a, b) in new columns. */
|
|
755
|
+
copy(a, b) {
|
|
756
|
+
const out = new _Columns(Math.max(0, b - a));
|
|
757
|
+
out.kind = this.kind;
|
|
758
|
+
out.n = Math.max(0, b - a);
|
|
759
|
+
if (this.kind === "any") {
|
|
760
|
+
out.items = this.items.slice(a, b);
|
|
761
|
+
return out;
|
|
762
|
+
}
|
|
763
|
+
out.time.set(this.time.subarray(a, b));
|
|
764
|
+
out.value.set(this.value.subarray(a, b));
|
|
765
|
+
out.has.set(this.has.subarray(a, b));
|
|
766
|
+
for (const k in this.extra)
|
|
767
|
+
out.extra[k] = this.extra[k].slice(a, b);
|
|
768
|
+
return out;
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
var isIndex = (p) => typeof p === "string" && p !== "" && String(+p >>> 0) === p;
|
|
772
|
+
function bound(x, n, fallback) {
|
|
773
|
+
if (x === void 0)
|
|
774
|
+
return fallback;
|
|
775
|
+
const v = Math.trunc(Number(x)) || 0;
|
|
776
|
+
return v < 0 ? Math.max(0, n + v) : Math.min(v, n);
|
|
777
|
+
}
|
|
778
|
+
var read = (cols, i) => cols.get(i);
|
|
779
|
+
function view(cols) {
|
|
780
|
+
const slice = (start, end) => {
|
|
781
|
+
const a = bound(start, cols.n, 0);
|
|
782
|
+
return view(cols.copy(a, Math.max(a, bound(end, cols.n, cols.n))));
|
|
783
|
+
};
|
|
784
|
+
return new Proxy([], {
|
|
785
|
+
get(target, prop, receiver) {
|
|
786
|
+
if (prop === "length")
|
|
787
|
+
return cols.n;
|
|
788
|
+
if (prop === PACKED)
|
|
789
|
+
return cols;
|
|
790
|
+
if (prop === "slice")
|
|
791
|
+
return slice;
|
|
792
|
+
if (isIndex(prop))
|
|
793
|
+
return read(cols, +prop);
|
|
794
|
+
return Reflect.get(target, prop, receiver);
|
|
795
|
+
},
|
|
796
|
+
set(target, prop, value) {
|
|
797
|
+
if (prop === "length") {
|
|
798
|
+
cols.setLength(value);
|
|
799
|
+
return true;
|
|
800
|
+
}
|
|
801
|
+
if (isIndex(prop)) {
|
|
802
|
+
cols.set(+prop, value);
|
|
803
|
+
return true;
|
|
804
|
+
}
|
|
805
|
+
return Reflect.set(target, prop, value);
|
|
806
|
+
},
|
|
807
|
+
has(target, prop) {
|
|
808
|
+
if (isIndex(prop))
|
|
809
|
+
return +prop < cols.n && (cols.kind === "any" ? +prop in cols.items : cols.has[+prop] === 1);
|
|
810
|
+
return Reflect.has(target, prop);
|
|
811
|
+
},
|
|
812
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
813
|
+
if (prop === "length")
|
|
814
|
+
return { value: cols.n, writable: true, enumerable: false, configurable: false };
|
|
815
|
+
if (isIndex(prop)) {
|
|
816
|
+
const i = +prop;
|
|
817
|
+
const present = i < cols.n && (cols.kind === "any" ? i in cols.items : cols.has[i] === 1);
|
|
818
|
+
return present ? { value: read(cols, i), writable: true, enumerable: true, configurable: true } : void 0;
|
|
819
|
+
}
|
|
820
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
821
|
+
},
|
|
822
|
+
ownKeys(target) {
|
|
823
|
+
const keys = [];
|
|
824
|
+
for (let i = 0; i < cols.n; i++)
|
|
825
|
+
if (cols.kind === "any" ? i in cols.items : cols.has[i] === 1)
|
|
826
|
+
keys.push(String(i));
|
|
827
|
+
for (const k of Reflect.ownKeys(target))
|
|
828
|
+
if (!isIndex(k))
|
|
829
|
+
keys.push(k);
|
|
830
|
+
return keys;
|
|
831
|
+
},
|
|
832
|
+
deleteProperty(target, prop) {
|
|
833
|
+
if (isIndex(prop)) {
|
|
834
|
+
const i = +prop;
|
|
835
|
+
if (cols.kind === "any")
|
|
836
|
+
delete cols.items[i];
|
|
837
|
+
else if (i < cols.n)
|
|
838
|
+
cols.set(i, void 0);
|
|
839
|
+
return true;
|
|
840
|
+
}
|
|
841
|
+
return Reflect.deleteProperty(target, prop);
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
var packed = false;
|
|
846
|
+
function setPackedSeries(on) {
|
|
847
|
+
packed = on;
|
|
848
|
+
}
|
|
849
|
+
function packedSeriesMode() {
|
|
850
|
+
return packed;
|
|
851
|
+
}
|
|
852
|
+
function packedSeries(list = []) {
|
|
853
|
+
const cols = new Columns(list.length);
|
|
854
|
+
for (let i = 0; i < list.length; i++)
|
|
855
|
+
if (i in list)
|
|
856
|
+
cols.set(i, list[i]);
|
|
857
|
+
cols.setLength(list.length);
|
|
858
|
+
return view(cols);
|
|
859
|
+
}
|
|
860
|
+
function packedColumns(v) {
|
|
861
|
+
if (v === null || typeof v !== "object" || !Array.isArray(v))
|
|
862
|
+
return null;
|
|
863
|
+
const cols = v[PACKED];
|
|
864
|
+
return cols && cols.kind === "points" && cols.has.subarray(0, cols.n).every((x) => x === 1) ? cols : null;
|
|
865
|
+
}
|
|
866
|
+
var isPackedSeries = (v) => v !== null && typeof v === "object" && Array.isArray(v) && v[PACKED] !== void 0;
|
|
867
|
+
function packedFromColumns(c) {
|
|
868
|
+
const cols = new Columns(0);
|
|
869
|
+
cols.kind = "points";
|
|
870
|
+
cols.n = c.n;
|
|
871
|
+
cols.time = c.time;
|
|
872
|
+
cols.value = c.value;
|
|
873
|
+
cols.has = new Uint8Array(c.n).fill(1);
|
|
874
|
+
cols.extra = c.extra;
|
|
875
|
+
return view(cols);
|
|
876
|
+
}
|
|
877
|
+
function packRunState(s) {
|
|
878
|
+
const own = s;
|
|
879
|
+
const fields = /* @__PURE__ */ new Map();
|
|
880
|
+
for (const k of Object.keys(own)) {
|
|
881
|
+
if (k === "series" || !Array.isArray(own[k]))
|
|
882
|
+
continue;
|
|
883
|
+
const names = fields.get(own[k]);
|
|
884
|
+
if (names)
|
|
885
|
+
names.push(k);
|
|
886
|
+
else
|
|
887
|
+
fields.set(own[k], [k]);
|
|
888
|
+
}
|
|
889
|
+
s.series = s.series.map((list) => {
|
|
890
|
+
const names = fields.get(list);
|
|
891
|
+
if (!names || isPackedSeries(list))
|
|
892
|
+
return list;
|
|
893
|
+
const p = packedSeries(list);
|
|
894
|
+
for (const k of names)
|
|
895
|
+
own[k] = p;
|
|
896
|
+
return p;
|
|
897
|
+
});
|
|
898
|
+
return s;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// src/live-run.ts
|
|
622
902
|
var LAST_BAR_FIELDS = /* @__PURE__ */ new Set(["lastBarConfirmed", "lastBarNew", "realtime", "now"]);
|
|
623
903
|
function sameChart(a, b, functions = true) {
|
|
624
904
|
const keys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
|
|
@@ -675,6 +955,7 @@ function createBarRun(study, chart = {}) {
|
|
|
675
955
|
let copy = new Float64Array(0);
|
|
676
956
|
let saved = null;
|
|
677
957
|
const copyVars = study.copyVars ?? ((v) => ({ ...v }));
|
|
958
|
+
const packed2 = packedSeriesMode();
|
|
678
959
|
const limits = study.drawings;
|
|
679
960
|
let lastKey;
|
|
680
961
|
let lastData;
|
|
@@ -713,6 +994,8 @@ function createBarRun(study, chart = {}) {
|
|
|
713
994
|
if (limits)
|
|
714
995
|
resetDrawings(limits);
|
|
715
996
|
state = study.init(bars, next);
|
|
997
|
+
if (packed2)
|
|
998
|
+
packRunState(state);
|
|
716
999
|
confirmed = 0;
|
|
717
1000
|
}
|
|
718
1001
|
const s = state;
|
|
@@ -1213,12 +1496,18 @@ export {
|
|
|
1213
1496
|
hasCalendar,
|
|
1214
1497
|
higherTimeframeBars,
|
|
1215
1498
|
isBarSource,
|
|
1499
|
+
isPackedSeries,
|
|
1216
1500
|
lastBarConfirmedOf,
|
|
1217
1501
|
liveAlertStates,
|
|
1218
1502
|
lowerTimeframe,
|
|
1219
1503
|
mintickOf,
|
|
1220
1504
|
nowOf,
|
|
1221
1505
|
otherSymbolChart,
|
|
1506
|
+
packRunState,
|
|
1507
|
+
packedColumns,
|
|
1508
|
+
packedFromColumns,
|
|
1509
|
+
packedSeries,
|
|
1510
|
+
packedSeriesMode,
|
|
1222
1511
|
periodChanges,
|
|
1223
1512
|
periodStarts,
|
|
1224
1513
|
rootOf,
|
|
@@ -1230,6 +1519,7 @@ export {
|
|
|
1230
1519
|
securityStarts,
|
|
1231
1520
|
sessionFlags,
|
|
1232
1521
|
sessionHoursOf,
|
|
1522
|
+
setPackedSeries,
|
|
1233
1523
|
spreadBars,
|
|
1234
1524
|
spreadOptions,
|
|
1235
1525
|
spreadSymbols,
|
package/dist/index.cjs
CHANGED
|
@@ -3577,14 +3577,19 @@ __export(src_exports, {
|
|
|
3577
3577
|
currencyOf: () => currencyOf,
|
|
3578
3578
|
foregroundColorOf: () => foregroundColorOf,
|
|
3579
3579
|
indicatorRegistry: () => indicatorRegistry,
|
|
3580
|
+
isPackedSeries: () => isPackedSeries,
|
|
3580
3581
|
lastBarConfirmedOf: () => lastBarConfirmedOf,
|
|
3581
3582
|
mintickOf: () => mintickOf,
|
|
3582
3583
|
nowOf: () => nowOf,
|
|
3583
3584
|
otherSymbolChart: () => otherSymbolChart,
|
|
3585
|
+
packedColumns: () => packedColumns,
|
|
3586
|
+
packedFromColumns: () => packedFromColumns,
|
|
3587
|
+
packedSeries: () => packedSeries,
|
|
3584
3588
|
rootOf: () => rootOf,
|
|
3585
3589
|
securityLowerTf: () => import_oakscriptjs310.securityLowerTf,
|
|
3586
3590
|
securityOther: () => import_oakscriptjs310.securityOther,
|
|
3587
3591
|
securityOtherValues: () => import_oakscriptjs310.securityOtherValues,
|
|
3592
|
+
setPackedSeries: () => setPackedSeries,
|
|
3588
3593
|
spreadBars: () => spreadBars,
|
|
3589
3594
|
spreadOptions: () => spreadOptions,
|
|
3590
3595
|
spreadSymbols: () => spreadSymbols,
|
|
@@ -3598,6 +3603,284 @@ __export(src_exports, {
|
|
|
3598
3603
|
});
|
|
3599
3604
|
module.exports = __toCommonJS(src_exports);
|
|
3600
3605
|
|
|
3606
|
+
// src/packed-series.ts
|
|
3607
|
+
var PACKED = Symbol.for("lightweight-charts-indicators/packed-series");
|
|
3608
|
+
function isPoint(p) {
|
|
3609
|
+
if (p === null || typeof p !== "object" || Array.isArray(p) || Object.getPrototypeOf(p) !== Object.prototype)
|
|
3610
|
+
return false;
|
|
3611
|
+
let k = 0;
|
|
3612
|
+
for (const f in p) {
|
|
3613
|
+
if (k === 0 && f !== "time")
|
|
3614
|
+
return false;
|
|
3615
|
+
if (k === 1)
|
|
3616
|
+
return f === "value" && typeof p.time === "number" && typeof p.value === "number";
|
|
3617
|
+
k++;
|
|
3618
|
+
}
|
|
3619
|
+
return false;
|
|
3620
|
+
}
|
|
3621
|
+
var Columns = class _Columns {
|
|
3622
|
+
/** What the list holds: decided by its first value; `any` keeps them in `items`. */
|
|
3623
|
+
kind = "none";
|
|
3624
|
+
n = 0;
|
|
3625
|
+
time;
|
|
3626
|
+
value;
|
|
3627
|
+
/** 1 where an entry is set (an index past the others leaves holes). */
|
|
3628
|
+
has;
|
|
3629
|
+
extra = {};
|
|
3630
|
+
items = [];
|
|
3631
|
+
constructor(capacity) {
|
|
3632
|
+
const cap = Math.max(16, capacity);
|
|
3633
|
+
this.time = new Float64Array(cap);
|
|
3634
|
+
this.value = new Float64Array(cap);
|
|
3635
|
+
this.has = new Uint8Array(cap);
|
|
3636
|
+
}
|
|
3637
|
+
grow(size2) {
|
|
3638
|
+
if (size2 <= this.value.length)
|
|
3639
|
+
return;
|
|
3640
|
+
const cap = Math.max(size2, this.value.length + (this.value.length >> 1));
|
|
3641
|
+
const t = new Float64Array(cap);
|
|
3642
|
+
t.set(this.time.subarray(0, this.n));
|
|
3643
|
+
const v = new Float64Array(cap);
|
|
3644
|
+
v.set(this.value.subarray(0, this.n));
|
|
3645
|
+
const h = new Uint8Array(cap);
|
|
3646
|
+
h.set(this.has.subarray(0, this.n));
|
|
3647
|
+
this.time = t;
|
|
3648
|
+
this.value = v;
|
|
3649
|
+
this.has = h;
|
|
3650
|
+
}
|
|
3651
|
+
get(i) {
|
|
3652
|
+
if (this.kind === "any")
|
|
3653
|
+
return this.items[i];
|
|
3654
|
+
if (i >= this.n || !this.has[i])
|
|
3655
|
+
return void 0;
|
|
3656
|
+
if (this.kind === "numbers")
|
|
3657
|
+
return this.value[i];
|
|
3658
|
+
const p = { time: this.time[i], value: this.value[i] };
|
|
3659
|
+
for (const k in this.extra) {
|
|
3660
|
+
const x = this.extra[k][i];
|
|
3661
|
+
if (x !== void 0)
|
|
3662
|
+
p[k] = x;
|
|
3663
|
+
}
|
|
3664
|
+
return p;
|
|
3665
|
+
}
|
|
3666
|
+
/** Every entry as it was written, in a plain list (the kinds no longer hold the next value). */
|
|
3667
|
+
toAny() {
|
|
3668
|
+
const items = new Array(this.n);
|
|
3669
|
+
for (let i = 0; i < this.n; i++)
|
|
3670
|
+
if (this.has[i])
|
|
3671
|
+
items[i] = this.get(i);
|
|
3672
|
+
this.kind = "any";
|
|
3673
|
+
this.items = items;
|
|
3674
|
+
this.time = new Float64Array(0);
|
|
3675
|
+
this.value = new Float64Array(0);
|
|
3676
|
+
this.has = new Uint8Array(0);
|
|
3677
|
+
this.extra = {};
|
|
3678
|
+
}
|
|
3679
|
+
set(i, p) {
|
|
3680
|
+
if (this.kind === "none" && p !== void 0)
|
|
3681
|
+
this.kind = isPoint(p) ? "points" : typeof p === "number" ? "numbers" : "any";
|
|
3682
|
+
const fits = this.kind === "any" || p === void 0 || (this.kind === "points" ? isPoint(p) : typeof p === "number");
|
|
3683
|
+
if (!fits)
|
|
3684
|
+
this.toAny();
|
|
3685
|
+
if (this.kind === "any") {
|
|
3686
|
+
this.items[i] = p;
|
|
3687
|
+
if (i >= this.n)
|
|
3688
|
+
this.n = i + 1;
|
|
3689
|
+
return;
|
|
3690
|
+
}
|
|
3691
|
+
if (i >= this.n) {
|
|
3692
|
+
this.grow(i + 1);
|
|
3693
|
+
this.has.fill(0, this.n, i);
|
|
3694
|
+
this.n = i + 1;
|
|
3695
|
+
}
|
|
3696
|
+
this.has[i] = p === void 0 ? 0 : 1;
|
|
3697
|
+
for (const k in this.extra) {
|
|
3698
|
+
const list = this.extra[k];
|
|
3699
|
+
if (i < list.length)
|
|
3700
|
+
list[i] = void 0;
|
|
3701
|
+
}
|
|
3702
|
+
if (p === void 0)
|
|
3703
|
+
return;
|
|
3704
|
+
if (this.kind === "numbers") {
|
|
3705
|
+
this.value[i] = p;
|
|
3706
|
+
return;
|
|
3707
|
+
}
|
|
3708
|
+
const q = p;
|
|
3709
|
+
this.time[i] = q.time;
|
|
3710
|
+
this.value[i] = q.value;
|
|
3711
|
+
for (const k in q) {
|
|
3712
|
+
if (k === "time" || k === "value")
|
|
3713
|
+
continue;
|
|
3714
|
+
const x = q[k];
|
|
3715
|
+
if (x !== void 0)
|
|
3716
|
+
(this.extra[k] ??= [])[i] = x;
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3719
|
+
setLength(len) {
|
|
3720
|
+
if (this.kind === "any") {
|
|
3721
|
+
this.items.length = len;
|
|
3722
|
+
this.n = len;
|
|
3723
|
+
return;
|
|
3724
|
+
}
|
|
3725
|
+
if (len < this.n) {
|
|
3726
|
+
for (const k in this.extra) {
|
|
3727
|
+
const list = this.extra[k];
|
|
3728
|
+
if (list.length > len)
|
|
3729
|
+
list.length = len;
|
|
3730
|
+
}
|
|
3731
|
+
} else if (len > this.n) {
|
|
3732
|
+
this.grow(len);
|
|
3733
|
+
this.has.fill(0, this.n, len);
|
|
3734
|
+
}
|
|
3735
|
+
this.n = len;
|
|
3736
|
+
}
|
|
3737
|
+
/** Entries [a, b) in new columns. */
|
|
3738
|
+
copy(a, b) {
|
|
3739
|
+
const out = new _Columns(Math.max(0, b - a));
|
|
3740
|
+
out.kind = this.kind;
|
|
3741
|
+
out.n = Math.max(0, b - a);
|
|
3742
|
+
if (this.kind === "any") {
|
|
3743
|
+
out.items = this.items.slice(a, b);
|
|
3744
|
+
return out;
|
|
3745
|
+
}
|
|
3746
|
+
out.time.set(this.time.subarray(a, b));
|
|
3747
|
+
out.value.set(this.value.subarray(a, b));
|
|
3748
|
+
out.has.set(this.has.subarray(a, b));
|
|
3749
|
+
for (const k in this.extra)
|
|
3750
|
+
out.extra[k] = this.extra[k].slice(a, b);
|
|
3751
|
+
return out;
|
|
3752
|
+
}
|
|
3753
|
+
};
|
|
3754
|
+
var isIndex = (p) => typeof p === "string" && p !== "" && String(+p >>> 0) === p;
|
|
3755
|
+
function bound(x, n, fallback) {
|
|
3756
|
+
if (x === void 0)
|
|
3757
|
+
return fallback;
|
|
3758
|
+
const v = Math.trunc(Number(x)) || 0;
|
|
3759
|
+
return v < 0 ? Math.max(0, n + v) : Math.min(v, n);
|
|
3760
|
+
}
|
|
3761
|
+
var read = (cols, i) => cols.get(i);
|
|
3762
|
+
function view(cols) {
|
|
3763
|
+
const slice = (start, end) => {
|
|
3764
|
+
const a = bound(start, cols.n, 0);
|
|
3765
|
+
return view(cols.copy(a, Math.max(a, bound(end, cols.n, cols.n))));
|
|
3766
|
+
};
|
|
3767
|
+
return new Proxy([], {
|
|
3768
|
+
get(target, prop, receiver) {
|
|
3769
|
+
if (prop === "length")
|
|
3770
|
+
return cols.n;
|
|
3771
|
+
if (prop === PACKED)
|
|
3772
|
+
return cols;
|
|
3773
|
+
if (prop === "slice")
|
|
3774
|
+
return slice;
|
|
3775
|
+
if (isIndex(prop))
|
|
3776
|
+
return read(cols, +prop);
|
|
3777
|
+
return Reflect.get(target, prop, receiver);
|
|
3778
|
+
},
|
|
3779
|
+
set(target, prop, value) {
|
|
3780
|
+
if (prop === "length") {
|
|
3781
|
+
cols.setLength(value);
|
|
3782
|
+
return true;
|
|
3783
|
+
}
|
|
3784
|
+
if (isIndex(prop)) {
|
|
3785
|
+
cols.set(+prop, value);
|
|
3786
|
+
return true;
|
|
3787
|
+
}
|
|
3788
|
+
return Reflect.set(target, prop, value);
|
|
3789
|
+
},
|
|
3790
|
+
has(target, prop) {
|
|
3791
|
+
if (isIndex(prop))
|
|
3792
|
+
return +prop < cols.n && (cols.kind === "any" ? +prop in cols.items : cols.has[+prop] === 1);
|
|
3793
|
+
return Reflect.has(target, prop);
|
|
3794
|
+
},
|
|
3795
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
3796
|
+
if (prop === "length")
|
|
3797
|
+
return { value: cols.n, writable: true, enumerable: false, configurable: false };
|
|
3798
|
+
if (isIndex(prop)) {
|
|
3799
|
+
const i = +prop;
|
|
3800
|
+
const present = i < cols.n && (cols.kind === "any" ? i in cols.items : cols.has[i] === 1);
|
|
3801
|
+
return present ? { value: read(cols, i), writable: true, enumerable: true, configurable: true } : void 0;
|
|
3802
|
+
}
|
|
3803
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
3804
|
+
},
|
|
3805
|
+
ownKeys(target) {
|
|
3806
|
+
const keys = [];
|
|
3807
|
+
for (let i = 0; i < cols.n; i++)
|
|
3808
|
+
if (cols.kind === "any" ? i in cols.items : cols.has[i] === 1)
|
|
3809
|
+
keys.push(String(i));
|
|
3810
|
+
for (const k of Reflect.ownKeys(target))
|
|
3811
|
+
if (!isIndex(k))
|
|
3812
|
+
keys.push(k);
|
|
3813
|
+
return keys;
|
|
3814
|
+
},
|
|
3815
|
+
deleteProperty(target, prop) {
|
|
3816
|
+
if (isIndex(prop)) {
|
|
3817
|
+
const i = +prop;
|
|
3818
|
+
if (cols.kind === "any")
|
|
3819
|
+
delete cols.items[i];
|
|
3820
|
+
else if (i < cols.n)
|
|
3821
|
+
cols.set(i, void 0);
|
|
3822
|
+
return true;
|
|
3823
|
+
}
|
|
3824
|
+
return Reflect.deleteProperty(target, prop);
|
|
3825
|
+
}
|
|
3826
|
+
});
|
|
3827
|
+
}
|
|
3828
|
+
var packed = false;
|
|
3829
|
+
function setPackedSeries(on2) {
|
|
3830
|
+
packed = on2;
|
|
3831
|
+
}
|
|
3832
|
+
function packedSeriesMode() {
|
|
3833
|
+
return packed;
|
|
3834
|
+
}
|
|
3835
|
+
function packedSeries(list = []) {
|
|
3836
|
+
const cols = new Columns(list.length);
|
|
3837
|
+
for (let i = 0; i < list.length; i++)
|
|
3838
|
+
if (i in list)
|
|
3839
|
+
cols.set(i, list[i]);
|
|
3840
|
+
cols.setLength(list.length);
|
|
3841
|
+
return view(cols);
|
|
3842
|
+
}
|
|
3843
|
+
function packedColumns(v) {
|
|
3844
|
+
if (v === null || typeof v !== "object" || !Array.isArray(v))
|
|
3845
|
+
return null;
|
|
3846
|
+
const cols = v[PACKED];
|
|
3847
|
+
return cols && cols.kind === "points" && cols.has.subarray(0, cols.n).every((x) => x === 1) ? cols : null;
|
|
3848
|
+
}
|
|
3849
|
+
var isPackedSeries = (v) => v !== null && typeof v === "object" && Array.isArray(v) && v[PACKED] !== void 0;
|
|
3850
|
+
function packedFromColumns(c4) {
|
|
3851
|
+
const cols = new Columns(0);
|
|
3852
|
+
cols.kind = "points";
|
|
3853
|
+
cols.n = c4.n;
|
|
3854
|
+
cols.time = c4.time;
|
|
3855
|
+
cols.value = c4.value;
|
|
3856
|
+
cols.has = new Uint8Array(c4.n).fill(1);
|
|
3857
|
+
cols.extra = c4.extra;
|
|
3858
|
+
return view(cols);
|
|
3859
|
+
}
|
|
3860
|
+
function packRunState(s) {
|
|
3861
|
+
const own = s;
|
|
3862
|
+
const fields = /* @__PURE__ */ new Map();
|
|
3863
|
+
for (const k of Object.keys(own)) {
|
|
3864
|
+
if (k === "series" || !Array.isArray(own[k]))
|
|
3865
|
+
continue;
|
|
3866
|
+
const names = fields.get(own[k]);
|
|
3867
|
+
if (names)
|
|
3868
|
+
names.push(k);
|
|
3869
|
+
else
|
|
3870
|
+
fields.set(own[k], [k]);
|
|
3871
|
+
}
|
|
3872
|
+
s.series = s.series.map((list) => {
|
|
3873
|
+
const names = fields.get(list);
|
|
3874
|
+
if (!names || isPackedSeries(list))
|
|
3875
|
+
return list;
|
|
3876
|
+
const p = packedSeries(list);
|
|
3877
|
+
for (const k of names)
|
|
3878
|
+
own[k] = p;
|
|
3879
|
+
return p;
|
|
3880
|
+
});
|
|
3881
|
+
return s;
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3601
3884
|
// src/standard/sma.ts
|
|
3602
3885
|
var import_oakscriptjs2 = require("oakscriptjs");
|
|
3603
3886
|
|
|
@@ -3659,6 +3942,7 @@ function createBarRun(study1286, chart = {}) {
|
|
|
3659
3942
|
let copy = new Float64Array(0);
|
|
3660
3943
|
let saved = null;
|
|
3661
3944
|
const copyVars = study1286.copyVars ?? ((v) => ({ ...v }));
|
|
3945
|
+
const packed2 = packedSeriesMode();
|
|
3662
3946
|
const limits = study1286.drawings;
|
|
3663
3947
|
let lastKey;
|
|
3664
3948
|
let lastData;
|
|
@@ -3697,6 +3981,8 @@ function createBarRun(study1286, chart = {}) {
|
|
|
3697
3981
|
if (limits)
|
|
3698
3982
|
(0, import_oakscriptjs.resetDrawings)(limits);
|
|
3699
3983
|
state = study1286.init(bars, next);
|
|
3984
|
+
if (packed2)
|
|
3985
|
+
packRunState(state);
|
|
3700
3986
|
confirmed = 0;
|
|
3701
3987
|
}
|
|
3702
3988
|
const s = state;
|
|
@@ -238376,8 +238662,8 @@ function calculate1316(bars, inputs = {}) {
|
|
|
238376
238662
|
const getX = lx2(getEW.l[4]);
|
|
238377
238663
|
const getY = ly2(getEW.l[4]);
|
|
238378
238664
|
const isSame2 = x1_ === lx2(getEW.l[2]) && x2_ === lx2(getEW.l[3]) && x3 === lx2(getEW.l[4]);
|
|
238379
|
-
const
|
|
238380
|
-
const isValid = x3 === getX && lt582(s * y6,
|
|
238665
|
+
const bound2 = s * getY + diff * cfg.i854;
|
|
238666
|
+
const isValid = x3 === getX && lt582(s * y6, bound2) && lt582(s * y4, bound2) && gt746(s * y5, s * getY);
|
|
238381
238667
|
const current = isSame2 && bX(getEW.bA) > x3;
|
|
238382
238668
|
if (isValid) {
|
|
238383
238669
|
const width = x6 - x2_;
|
|
@@ -239063,7 +239349,7 @@ function calculate1318(bars, inputs = {}, chart) {
|
|
|
239063
239349
|
const ms = n > 0 && bars[0].time >= 1e12;
|
|
239064
239350
|
const tMs = bars.map((b) => ms ? b.time : b.time * 1e3);
|
|
239065
239351
|
const start = Math.max(0, n - CALC_BARS);
|
|
239066
|
-
const
|
|
239352
|
+
const view2 = bars.slice(start);
|
|
239067
239353
|
const timenow = nowOf(chart);
|
|
239068
239354
|
const MINTICK = mintickOf(chart);
|
|
239069
239355
|
const CHART_FG = foregroundColorOf(chart);
|
|
@@ -239088,8 +239374,8 @@ function calculate1318(bars, inputs = {}, chart) {
|
|
|
239088
239374
|
const T20 = (i) => i >= start ? tMs[i] : NaN;
|
|
239089
239375
|
const MX = (i) => i < start ? NaN : obbUseBody ? Math.max(bars[i].close, bars[i].open) : bars[i].high;
|
|
239090
239376
|
const MN = (i) => i < start ? NaN : obbUseBody ? Math.min(bars[i].close, bars[i].open) : bars[i].low;
|
|
239091
|
-
const atr = import_oakscriptjs1198.ta.atr(
|
|
239092
|
-
const atr200Arr = import_oakscriptjs1198.ta.atr(
|
|
239377
|
+
const atr = import_oakscriptjs1198.ta.atr(view2, 10).toArray().map((v) => v ?? NaN);
|
|
239378
|
+
const atr200Arr = import_oakscriptjs1198.ta.atr(view2, 200).toArray().map((v) => v ?? NaN);
|
|
239093
239379
|
const ictms = () => ({
|
|
239094
239380
|
lastPrice: NaN,
|
|
239095
239381
|
midPrice: NaN,
|
|
@@ -406016,10 +406302,10 @@ function calculate1744(bars, inputs = {}, chart) {
|
|
|
406016
406302
|
const timePoint = (start, units) => start + units / mult * msByPeriodUnit;
|
|
406017
406303
|
const roundTick = (price) => import_oakscriptjs1621.math.round(price / mintick) * mintick;
|
|
406018
406304
|
const deltaTick = (p1, p2) => p1 / mintick - p2 / mintick;
|
|
406019
|
-
const
|
|
406305
|
+
const isIndex2 = symbolTypeOf(chart) === "index";
|
|
406020
406306
|
const isPeriodOK = tfInfo.isminutes && mult <= 720 && cfg.period % 2 === 0 && cfg.period % mult === 0;
|
|
406021
|
-
const customHelpHeader =
|
|
406022
|
-
const isGoodToGo = !
|
|
406307
|
+
const customHelpHeader = isIndex2 ? "Ticker not allowed! It is an index, select a ticker with volume data." : !isPeriodOK ? "Parameters not allowed! Select a new period size and/or chart timeframe." : "HELP INFO";
|
|
406308
|
+
const isGoodToGo = !isIndex2 && !cfg.showHelp && isPeriodOK;
|
|
406023
406309
|
const lastConfirmed = lastBarConfirmedOf(chart);
|
|
406024
406310
|
const now = nowOf(chart);
|
|
406025
406311
|
(0, import_oakscriptjs1621.resetDrawings)({ line: 500, label: 500 });
|
|
@@ -462546,4 +462832,4 @@ var registryPart12 = [
|
|
|
462546
462832
|
}
|
|
462547
462833
|
];
|
|
462548
462834
|
var indicatorRegistry = [...registryPart1, ...registryPart11, ...registryPart2, ...registryPart3, ...registryPart4, ...registryPart5, ...registryPart6, ...registryPart7, ...registryPart8, ...registryPart9, ...registryPart10, ...registryPart12].map(withReferenceNames).map(withValueFormat).map(withStyleOutputs).map(withAlertConditions);
|
|
462549
|
-
var version = "0.
|
|
462835
|
+
var version = "0.21.0";
|