oakscriptjs 0.15.2 → 0.15.4

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.
Files changed (178) hide show
  1. package/dist/cjs/check/format.d.ts.map +1 -1
  2. package/dist/cjs/check/format.js +5 -0
  3. package/dist/cjs/check/format.js.map +2 -2
  4. package/dist/cjs/check/harness.d.ts +24 -0
  5. package/dist/cjs/check/harness.d.ts.map +1 -1
  6. package/dist/cjs/check/harness.js +33 -0
  7. package/dist/cjs/check/harness.js.map +2 -2
  8. package/dist/cjs/check/index.d.ts +9 -0
  9. package/dist/cjs/check/index.d.ts.map +1 -1
  10. package/dist/cjs/check/index.js +7 -0
  11. package/dist/cjs/check/index.js.map +2 -2
  12. package/dist/cjs/color/index.d.ts.map +1 -1
  13. package/dist/cjs/color/index.js +19 -2
  14. package/dist/cjs/color/index.js.map +2 -2
  15. package/dist/cjs/color/parse.d.ts +8 -6
  16. package/dist/cjs/color/parse.d.ts.map +1 -1
  17. package/dist/cjs/color/parse.js +15 -2
  18. package/dist/cjs/color/parse.js.map +2 -2
  19. package/dist/cjs/drawing/registry.d.ts +32 -0
  20. package/dist/cjs/drawing/registry.d.ts.map +1 -1
  21. package/dist/cjs/drawing/registry.js +179 -45
  22. package/dist/cjs/drawing/registry.js.map +2 -2
  23. package/dist/cjs/index.d.ts +2 -1
  24. package/dist/cjs/index.d.ts.map +1 -1
  25. package/dist/cjs/index.js +3 -1
  26. package/dist/cjs/index.js.map +2 -2
  27. package/dist/cjs/runtime/series.d.ts +16 -0
  28. package/dist/cjs/runtime/series.d.ts.map +1 -1
  29. package/dist/cjs/runtime/series.js +19 -2
  30. package/dist/cjs/runtime/series.js.map +2 -2
  31. package/dist/cjs/script/closure-writes.d.ts +16 -0
  32. package/dist/cjs/script/closure-writes.d.ts.map +1 -0
  33. package/dist/cjs/script/closure-writes.js +435 -0
  34. package/dist/cjs/script/closure-writes.js.map +7 -0
  35. package/dist/cjs/script/globals.d.ts +2 -0
  36. package/dist/cjs/script/globals.d.ts.map +1 -1
  37. package/dist/cjs/script/globals.js.map +1 -1
  38. package/dist/cjs/script/incremental.d.ts +140 -0
  39. package/dist/cjs/script/incremental.d.ts.map +1 -0
  40. package/dist/cjs/script/incremental.js +142 -0
  41. package/dist/cjs/script/incremental.js.map +7 -0
  42. package/dist/cjs/script/index.d.ts +116 -31
  43. package/dist/cjs/script/index.d.ts.map +1 -1
  44. package/dist/cjs/script/index.js +471 -25
  45. package/dist/cjs/script/index.js.map +3 -3
  46. package/dist/cjs/session/bars.d.ts +3 -0
  47. package/dist/cjs/session/bars.d.ts.map +1 -1
  48. package/dist/cjs/session/bars.js +10 -3
  49. package/dist/cjs/session/bars.js.map +2 -2
  50. package/dist/cjs/session/calendar.d.ts +19 -6
  51. package/dist/cjs/session/calendar.d.ts.map +1 -1
  52. package/dist/cjs/session/calendar.js +57 -18
  53. package/dist/cjs/session/calendar.js.map +2 -2
  54. package/dist/cjs/session/context.d.ts.map +1 -1
  55. package/dist/cjs/session/context.js +25 -8
  56. package/dist/cjs/session/context.js.map +2 -2
  57. package/dist/cjs/str/numberformat.d.ts.map +1 -1
  58. package/dist/cjs/str/numberformat.js +23 -0
  59. package/dist/cjs/str/numberformat.js.map +2 -2
  60. package/dist/cjs/strategy/index.d.ts +8 -0
  61. package/dist/cjs/strategy/index.d.ts.map +1 -1
  62. package/dist/cjs/strategy/index.js.map +1 -1
  63. package/dist/cjs/ta/running-sum.d.ts.map +1 -1
  64. package/dist/cjs/ta/running-sum.js +72 -3
  65. package/dist/cjs/ta/running-sum.js.map +2 -2
  66. package/dist/cjs/ta/step.d.ts +476 -0
  67. package/dist/cjs/ta/step.d.ts.map +1 -0
  68. package/dist/cjs/ta/step.js +1000 -0
  69. package/dist/cjs/ta/step.js.map +7 -0
  70. package/dist/cjs/ta-series.d.ts +1 -1
  71. package/dist/cjs/ta-series.js +3 -3
  72. package/dist/cjs/ta-series.js.map +1 -1
  73. package/dist/cjs/time/timezone.d.ts +13 -1
  74. package/dist/cjs/time/timezone.d.ts.map +1 -1
  75. package/dist/cjs/time/timezone.js +52 -13
  76. package/dist/cjs/time/timezone.js.map +2 -2
  77. package/dist/esm/check/format.d.ts.map +1 -1
  78. package/dist/esm/check/format.js +5 -0
  79. package/dist/esm/check/format.js.map +1 -1
  80. package/dist/esm/check/harness.d.ts +24 -0
  81. package/dist/esm/check/harness.d.ts.map +1 -1
  82. package/dist/esm/check/harness.js +40 -6
  83. package/dist/esm/check/harness.js.map +1 -1
  84. package/dist/esm/check/index.d.ts +9 -0
  85. package/dist/esm/check/index.d.ts.map +1 -1
  86. package/dist/esm/check/index.js +11 -1
  87. package/dist/esm/check/index.js.map +1 -1
  88. package/dist/esm/color/index.d.ts.map +1 -1
  89. package/dist/esm/color/index.js +23 -3
  90. package/dist/esm/color/index.js.map +1 -1
  91. package/dist/esm/color/parse.d.ts +8 -6
  92. package/dist/esm/color/parse.d.ts.map +1 -1
  93. package/dist/esm/color/parse.js +19 -2
  94. package/dist/esm/color/parse.js.map +1 -1
  95. package/dist/esm/drawing/registry.d.ts +32 -0
  96. package/dist/esm/drawing/registry.d.ts.map +1 -1
  97. package/dist/esm/drawing/registry.js +214 -51
  98. package/dist/esm/drawing/registry.js.map +1 -1
  99. package/dist/esm/index.d.ts +2 -1
  100. package/dist/esm/index.d.ts.map +1 -1
  101. package/dist/esm/index.js +3 -1
  102. package/dist/esm/index.js.map +1 -1
  103. package/dist/esm/runtime/series.d.ts +16 -0
  104. package/dist/esm/runtime/series.d.ts.map +1 -1
  105. package/dist/esm/runtime/series.js +21 -1
  106. package/dist/esm/runtime/series.js.map +1 -1
  107. package/dist/esm/script/closure-writes.d.ts +16 -0
  108. package/dist/esm/script/closure-writes.d.ts.map +1 -0
  109. package/dist/esm/script/closure-writes.js +323 -0
  110. package/dist/esm/script/closure-writes.js.map +1 -0
  111. package/dist/esm/script/globals.d.ts +2 -0
  112. package/dist/esm/script/globals.d.ts.map +1 -1
  113. package/dist/esm/script/globals.js.map +1 -1
  114. package/dist/esm/script/incremental.d.ts +140 -0
  115. package/dist/esm/script/incremental.d.ts.map +1 -0
  116. package/dist/esm/script/incremental.js +173 -0
  117. package/dist/esm/script/incremental.js.map +1 -0
  118. package/dist/esm/script/index.d.ts +116 -31
  119. package/dist/esm/script/index.d.ts.map +1 -1
  120. package/dist/esm/script/index.js +561 -24
  121. package/dist/esm/script/index.js.map +1 -1
  122. package/dist/esm/session/bars.d.ts +3 -0
  123. package/dist/esm/session/bars.d.ts.map +1 -1
  124. package/dist/esm/session/bars.js +11 -3
  125. package/dist/esm/session/bars.js.map +1 -1
  126. package/dist/esm/session/calendar.d.ts +19 -6
  127. package/dist/esm/session/calendar.d.ts.map +1 -1
  128. package/dist/esm/session/calendar.js +74 -21
  129. package/dist/esm/session/calendar.js.map +1 -1
  130. package/dist/esm/session/context.d.ts.map +1 -1
  131. package/dist/esm/session/context.js +34 -9
  132. package/dist/esm/session/context.js.map +1 -1
  133. package/dist/esm/str/numberformat.d.ts.map +1 -1
  134. package/dist/esm/str/numberformat.js +30 -0
  135. package/dist/esm/str/numberformat.js.map +1 -1
  136. package/dist/esm/strategy/index.d.ts +8 -0
  137. package/dist/esm/strategy/index.d.ts.map +1 -1
  138. package/dist/esm/ta/running-sum.d.ts.map +1 -1
  139. package/dist/esm/ta/running-sum.js +79 -4
  140. package/dist/esm/ta/running-sum.js.map +1 -1
  141. package/dist/esm/ta/step.d.ts +476 -0
  142. package/dist/esm/ta/step.d.ts.map +1 -0
  143. package/dist/esm/ta/step.js +1089 -0
  144. package/dist/esm/ta/step.js.map +1 -0
  145. package/dist/esm/ta-series.d.ts +1 -1
  146. package/dist/esm/ta-series.js +4 -4
  147. package/dist/esm/time/timezone.d.ts +13 -1
  148. package/dist/esm/time/timezone.d.ts.map +1 -1
  149. package/dist/esm/time/timezone.js +78 -17
  150. package/dist/esm/time/timezone.js.map +1 -1
  151. package/package.json +1 -1
  152. package/skills/oakscript/SKILL.md +2 -2
  153. package/skills/oakscript/reference/check.md +5 -0
  154. package/skills/oakscript/reference/errors.md +0 -1
  155. package/skills/oakscript/reference/pine-differences.md +1 -2
  156. package/skills/oakscript/reference/plotting.md +5 -7
  157. package/skills/oakscript/reference/script-structure.md +6 -0
  158. package/src/check/format.ts +7 -0
  159. package/src/check/harness.ts +57 -0
  160. package/src/check/index.ts +16 -0
  161. package/src/color/index.ts +22 -3
  162. package/src/color/parse.ts +28 -3
  163. package/src/drawing/registry.ts +233 -50
  164. package/src/index.ts +4 -1
  165. package/src/runtime/series.ts +33 -1
  166. package/src/script/closure-writes.ts +279 -0
  167. package/src/script/globals.ts +2 -0
  168. package/src/script/incremental.ts +246 -0
  169. package/src/script/index.ts +695 -26
  170. package/src/session/bars.ts +11 -3
  171. package/src/session/calendar.ts +84 -21
  172. package/src/session/context.ts +36 -9
  173. package/src/str/numberformat.ts +29 -0
  174. package/src/strategy/index.ts +8 -0
  175. package/src/ta/running-sum.ts +78 -3
  176. package/src/ta/step.ts +1145 -0
  177. package/src/ta-series.ts +4 -4
  178. package/src/time/timezone.ts +76 -15
@@ -0,0 +1,1000 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var step_exports = {};
20
+ __export(step_exports, {
21
+ AtrStep: () => AtrStep,
22
+ BarssinceStep: () => BarssinceStep,
23
+ BbStep: () => BbStep,
24
+ CciStep: () => CciStep,
25
+ ChangeStep: () => ChangeStep,
26
+ CorrelationStep: () => CorrelationStep,
27
+ CrossStep: () => CrossStep,
28
+ CrossoverStep: () => CrossoverStep,
29
+ CrossunderStep: () => CrossunderStep,
30
+ CumStep: () => CumStep,
31
+ DevStep: () => DevStep,
32
+ DmiStep: () => DmiStep,
33
+ EmaStep: () => EmaStep,
34
+ HighestStep: () => HighestStep,
35
+ HmaStep: () => HmaStep,
36
+ LinregStep: () => LinregStep,
37
+ LowestStep: () => LowestStep,
38
+ MacdStep: () => MacdStep,
39
+ MedianStep: () => MedianStep,
40
+ MfiStep: () => MfiStep,
41
+ MomStep: () => MomStep,
42
+ ObvStep: () => ObvStep,
43
+ PercentrankStep: () => PercentrankStep,
44
+ RmaStep: () => RmaStep,
45
+ RocStep: () => RocStep,
46
+ RsiStep: () => RsiStep,
47
+ SmaStep: () => SmaStep,
48
+ StdevStep: () => StdevStep,
49
+ StochStep: () => StochStep,
50
+ SumStep: () => SumStep,
51
+ SupertrendStep: () => SupertrendStep,
52
+ TrStep: () => TrStep,
53
+ ValuewhenStep: () => ValuewhenStep,
54
+ VarianceStep: () => VarianceStep,
55
+ VwmaStep: () => VwmaStep,
56
+ WmaStep: () => WmaStep,
57
+ WprStep: () => WprStep,
58
+ taStep: () => taStep
59
+ });
60
+ module.exports = __toCommonJS(step_exports);
61
+ var import_running_sum = require("./running-sum.js");
62
+ var import_limits = require("./limits.js");
63
+ var import_compare = require("../compare/index.js");
64
+ const skipped = (v) => v === void 0 || v === null || !Number.isFinite(v);
65
+ class SumStep {
66
+ sum = new import_running_sum.RunningSum();
67
+ stepped = false;
68
+ step(value, length) {
69
+ const len = Math.floor(length);
70
+ this.stepped = len >= 1;
71
+ if (!this.stepped) return NaN;
72
+ return (0, import_running_sum.isNa)(value) ? this.sum.stepNa(len) : this.sum.step(value, len);
73
+ }
74
+ commit() {
75
+ if (this.stepped) this.sum.commit();
76
+ this.stepped = false;
77
+ }
78
+ /** Forget the steps of the current bar (the bar is not in the history) */
79
+ discard() {
80
+ this.stepped = false;
81
+ }
82
+ }
83
+ class SmaStep {
84
+ sum = new SumStep();
85
+ step(value, length) {
86
+ (0, import_limits.checkSumLength)("ta.sma", Math.floor(length), 0);
87
+ return this.sum.step(value, length) / Math.floor(length);
88
+ }
89
+ commit() {
90
+ this.sum.commit();
91
+ }
92
+ }
93
+ class VarianceStep {
94
+ constructor(name = "ta.variance") {
95
+ this.name = name;
96
+ }
97
+ name;
98
+ sums = new SumStep();
99
+ squares = new SumStep();
100
+ step(value, length, biased = true) {
101
+ const len = Math.floor(length);
102
+ (0, import_limits.checkSumLength)(this.name, len, 0);
103
+ const sum = this.sums.step(value, len);
104
+ const sq = this.squares.step((0, import_running_sum.isNa)(value) ? NaN : value * value, len);
105
+ if ((biased ? len : len - 1) <= 0) return NaN;
106
+ const mean = sum / len;
107
+ return biased ? sq / len - mean * mean : sq / (len - 1) - mean * sum / (len - 1);
108
+ }
109
+ commit() {
110
+ this.sums.commit();
111
+ this.squares.commit();
112
+ }
113
+ }
114
+ class StdevStep {
115
+ variance = new VarianceStep("ta.stdev");
116
+ step(value, length, biased = true) {
117
+ const v = this.variance.step(value, length, biased);
118
+ return Number.isNaN(v) ? NaN : v > 0 ? Math.sqrt(v) : 0;
119
+ }
120
+ commit() {
121
+ this.variance.commit();
122
+ }
123
+ }
124
+ class SeededAverage {
125
+ seed = new SumStep();
126
+ value = NaN;
127
+ count = 0;
128
+ stepped = false;
129
+ /** The last step of the bar added its value to the seed sum */
130
+ seeded = false;
131
+ nextValue = NaN;
132
+ nextCount = 0;
133
+ len;
134
+ constructor(name, length) {
135
+ (0, import_limits.checkPositiveLength)(name, length, 0);
136
+ this.len = Math.floor(length);
137
+ }
138
+ step(value) {
139
+ this.stepped = true;
140
+ this.seeded = false;
141
+ this.nextValue = this.value;
142
+ this.nextCount = this.count;
143
+ if (skipped(value)) return NaN;
144
+ this.nextCount = this.count + 1;
145
+ if (this.count < this.len) {
146
+ this.seeded = true;
147
+ const s = this.seed.step(value, this.len);
148
+ if (this.nextCount < this.len) return NaN;
149
+ this.nextValue = s / this.len;
150
+ return this.nextValue;
151
+ }
152
+ this.nextValue = this.next(value, this.value);
153
+ return this.nextValue;
154
+ }
155
+ commit() {
156
+ if (!this.stepped) return;
157
+ this.stepped = false;
158
+ if (this.seeded) this.seed.commit();
159
+ else this.seed.discard();
160
+ this.value = this.nextValue;
161
+ this.count = this.nextCount;
162
+ }
163
+ }
164
+ class EmaStep extends SeededAverage {
165
+ multiplier;
166
+ constructor(length) {
167
+ super("ema", length);
168
+ this.multiplier = 2 / (this.len + 1);
169
+ }
170
+ next(value, previous) {
171
+ return (value - previous) * this.multiplier + previous;
172
+ }
173
+ }
174
+ class RmaStep extends SeededAverage {
175
+ constructor(length, name = "rma") {
176
+ super(name, length);
177
+ }
178
+ next(value, previous) {
179
+ return (value + (this.len - 1) * previous) / this.len;
180
+ }
181
+ }
182
+ function wmaAdd(a, b) {
183
+ const sum = a + b;
184
+ return Math.abs(sum) <= 1e-10 * Math.max(1, Math.abs(a) + Math.abs(b)) ? 0 : sum;
185
+ }
186
+ class WmaStep {
187
+ filled = [];
188
+ last = NaN;
189
+ count = 0;
190
+ stepped = false;
191
+ nextFilled = NaN;
192
+ nextValid = false;
193
+ step(value, length) {
194
+ const len = Math.floor(length);
195
+ (0, import_limits.checkPositiveLength)("wma", len, this.filled.length);
196
+ this.stepped = true;
197
+ const na = skipped(value);
198
+ this.nextValid = !na;
199
+ this.nextFilled = na ? this.last : value;
200
+ if (na || !(len >= 1) || this.count + 1 < len) return NaN;
201
+ const n = this.filled.length;
202
+ let sum = 0;
203
+ let weightSum = 0;
204
+ for (let j = len - 1; j >= 0; j--) {
205
+ const weight = len - j;
206
+ sum = wmaAdd(sum, (j === 0 ? this.nextFilled : this.filled[n - j]) * weight);
207
+ weightSum += weight;
208
+ }
209
+ return sum / weightSum;
210
+ }
211
+ commit() {
212
+ if (!this.stepped) return;
213
+ this.stepped = false;
214
+ if (this.nextValid) {
215
+ this.last = this.nextFilled;
216
+ this.count++;
217
+ }
218
+ this.filled.push(this.nextFilled);
219
+ }
220
+ }
221
+ class HistoryStep {
222
+ history = [];
223
+ stepped = false;
224
+ pending = NaN;
225
+ /** The current bar's value, kept by commit() */
226
+ keep(value) {
227
+ this.stepped = true;
228
+ this.pending = value;
229
+ }
230
+ /** The value `k` bars back (k >= 1), NaN before the first bar */
231
+ back(k) {
232
+ const i = this.history.length - k;
233
+ return i >= 0 ? this.history[i] : NaN;
234
+ }
235
+ commit() {
236
+ if (!this.stepped) return;
237
+ this.stepped = false;
238
+ this.history.push(this.pending);
239
+ }
240
+ }
241
+ class ChangeStep extends HistoryStep {
242
+ constructor(length = 1) {
243
+ super();
244
+ this.length = length;
245
+ (0, import_limits.checkPositiveLength)("change", length, 0);
246
+ }
247
+ length;
248
+ step(value) {
249
+ this.keep(value);
250
+ return this.history.length < this.length ? NaN : value - this.back(this.length);
251
+ }
252
+ }
253
+ class MomStep extends HistoryStep {
254
+ constructor(length) {
255
+ super();
256
+ this.length = length;
257
+ (0, import_limits.checkPositiveLength)("mom", length, 0);
258
+ }
259
+ length;
260
+ step(value) {
261
+ this.keep(value);
262
+ if (this.history.length < this.length) return NaN;
263
+ const old = this.back(this.length);
264
+ return Number.isNaN(value) || Number.isNaN(old) ? NaN : value - old;
265
+ }
266
+ }
267
+ class RocStep extends HistoryStep {
268
+ constructor(length) {
269
+ super();
270
+ this.length = length;
271
+ (0, import_limits.checkPositiveLength)("roc", length, 0);
272
+ }
273
+ length;
274
+ step(value) {
275
+ this.keep(value);
276
+ if (this.history.length < this.length) return NaN;
277
+ const old = this.back(this.length);
278
+ if (Number.isNaN(old) || Number.isNaN(value)) return NaN;
279
+ return 100 * (value - old) / old;
280
+ }
281
+ }
282
+ class TrStep extends HistoryStep {
283
+ constructor(handleNa = false) {
284
+ super();
285
+ this.handleNa = handleNa;
286
+ }
287
+ handleNa;
288
+ step(high, low, close) {
289
+ this.keep(close);
290
+ const prev = this.back(1);
291
+ if (this.history.length === 0 || Number.isNaN(prev)) return this.handleNa ? high - low : NaN;
292
+ return Math.max(high - low, Math.abs(high - prev), Math.abs(low - prev));
293
+ }
294
+ }
295
+ class AtrStep {
296
+ tr = new TrStep(true);
297
+ rma;
298
+ constructor(length) {
299
+ (0, import_limits.checkPositiveLength)("atr->rma", length, 0);
300
+ this.rma = new RmaStep(length, "atr->rma");
301
+ }
302
+ step(high, low, close) {
303
+ return this.rma.step(this.tr.step(high, low, close));
304
+ }
305
+ commit() {
306
+ this.tr.commit();
307
+ this.rma.commit();
308
+ }
309
+ }
310
+ class RsiStep extends HistoryStep {
311
+ gains;
312
+ losses;
313
+ constructor(length) {
314
+ super();
315
+ (0, import_limits.checkPositiveLength)("rsi", length, 0, "y");
316
+ this.gains = new RmaStep(length);
317
+ this.losses = new RmaStep(length);
318
+ }
319
+ step(value) {
320
+ this.keep(value);
321
+ if (this.history.length === 0) return NaN;
322
+ const c = value - this.back(1);
323
+ const up = this.gains.step(Number.isNaN(c) ? NaN : c > 0 ? c : 0);
324
+ const down = this.losses.step(Number.isNaN(c) ? NaN : c < 0 ? -c : 0);
325
+ if ((0, import_compare.eq)(down, 0)) return 100;
326
+ if ((0, import_compare.eq)(up, 0)) return 0;
327
+ return 100 - 100 / (1 + up / down);
328
+ }
329
+ commit() {
330
+ super.commit();
331
+ this.gains.commit();
332
+ this.losses.commit();
333
+ }
334
+ }
335
+ class CumStep {
336
+ sum = 0;
337
+ next = 0;
338
+ stepped = false;
339
+ step(value) {
340
+ this.stepped = true;
341
+ this.next = this.sum;
342
+ if (!Number.isFinite(value)) return NaN;
343
+ this.next = this.sum + value;
344
+ return this.next;
345
+ }
346
+ commit() {
347
+ if (this.stepped) this.sum = this.next;
348
+ this.stepped = false;
349
+ }
350
+ }
351
+ class CrossTestStep {
352
+ constructor(test) {
353
+ this.test = test;
354
+ }
355
+ test;
356
+ prevA = NaN;
357
+ prevB = NaN;
358
+ nextA = NaN;
359
+ nextB = NaN;
360
+ stepped = false;
361
+ step(a, b) {
362
+ this.stepped = true;
363
+ const both = !Number.isNaN(a) && !Number.isNaN(b);
364
+ this.nextA = both ? a : this.prevA;
365
+ this.nextB = both ? b : this.prevB;
366
+ return this.test(a, b, this.prevA, this.prevB);
367
+ }
368
+ commit() {
369
+ if (!this.stepped) return;
370
+ this.stepped = false;
371
+ this.prevA = this.nextA;
372
+ this.prevB = this.nextB;
373
+ }
374
+ }
375
+ class CrossoverStep extends CrossTestStep {
376
+ constructor() {
377
+ super((a, b, pa, pb) => a > b && pa <= pb);
378
+ }
379
+ }
380
+ class CrossunderStep extends CrossTestStep {
381
+ constructor() {
382
+ super((a, b, pa, pb) => a < b && pa >= pb);
383
+ }
384
+ }
385
+ class CrossStep {
386
+ side = 0;
387
+ next = 0;
388
+ stepped = false;
389
+ step(a, b) {
390
+ this.stepped = true;
391
+ this.next = this.side;
392
+ if (Number.isNaN(a) || Number.isNaN(b)) return false;
393
+ const crossed = this.side < 0 && a > b || this.side > 0 && a < b;
394
+ if (a < b) this.next = -1;
395
+ else if (a > b) this.next = 1;
396
+ return crossed;
397
+ }
398
+ commit() {
399
+ if (this.stepped) this.side = this.next;
400
+ this.stepped = false;
401
+ }
402
+ }
403
+ class BarssinceStep {
404
+ value = NaN;
405
+ next = NaN;
406
+ stepped = false;
407
+ step(condition) {
408
+ this.stepped = true;
409
+ this.next = condition ? 0 : Number.isNaN(this.value) ? NaN : this.value + 1;
410
+ return this.next;
411
+ }
412
+ commit() {
413
+ if (this.stepped) this.value = this.next;
414
+ this.stepped = false;
415
+ }
416
+ }
417
+ class ValuewhenStep {
418
+ constructor(occurrence) {
419
+ this.occurrence = occurrence;
420
+ }
421
+ occurrence;
422
+ values = [];
423
+ pending = null;
424
+ stepped = false;
425
+ step(condition, value) {
426
+ this.stepped = true;
427
+ this.pending = condition ? value : null;
428
+ const n = this.values.length + (condition ? 1 : 0);
429
+ const k = n - 1 - this.occurrence;
430
+ if (k < 0 || k >= n) return NaN;
431
+ return k === this.values.length ? value : this.values[k] ?? NaN;
432
+ }
433
+ commit() {
434
+ if (this.stepped && this.pending !== null) this.values.push(this.pending);
435
+ this.stepped = false;
436
+ this.pending = null;
437
+ }
438
+ }
439
+ class ObvStep extends HistoryStep {
440
+ cum = new CumStep();
441
+ step(close, volume) {
442
+ this.keep(close);
443
+ return this.cum.step(this.history.length === 0 ? NaN : Math.sign(close - this.back(1)) * volume);
444
+ }
445
+ commit() {
446
+ super.commit();
447
+ this.cum.commit();
448
+ }
449
+ }
450
+ class ExtremeStep {
451
+ constructor(lowest) {
452
+ this.lowest = lowest;
453
+ }
454
+ lowest;
455
+ values = [];
456
+ bars = 0;
457
+ pending = NaN;
458
+ stepped = false;
459
+ step(value, length) {
460
+ (0, import_limits.checkWindowLength)(this.lowest ? "lowest" : "highest", length, this.bars);
461
+ this.stepped = true;
462
+ this.pending = value;
463
+ const len = Math.trunc(length);
464
+ const own = !skipped(value);
465
+ const n = this.values.length + (own ? 1 : 0);
466
+ if (this.bars < len - 1 || n === 0) return NaN;
467
+ let best = own ? value : this.values[n - 1];
468
+ const from = Math.max(0, n - len);
469
+ for (let i = from; i < this.values.length; i++) {
470
+ const v = this.values[i];
471
+ best = this.lowest ? Math.min(best, v) : Math.max(best, v);
472
+ }
473
+ return best;
474
+ }
475
+ commit() {
476
+ if (!this.stepped) return;
477
+ this.stepped = false;
478
+ this.bars++;
479
+ if (!skipped(this.pending)) this.values.push(this.pending);
480
+ }
481
+ }
482
+ class HighestStep extends ExtremeStep {
483
+ constructor() {
484
+ super(false);
485
+ }
486
+ }
487
+ class LowestStep extends ExtremeStep {
488
+ constructor() {
489
+ super(true);
490
+ }
491
+ }
492
+ class MacdStep {
493
+ fast;
494
+ slow;
495
+ signal;
496
+ constructor(fastLength, slowLength, signalLength) {
497
+ this.fast = new EmaStep(fastLength);
498
+ this.slow = new EmaStep(slowLength);
499
+ this.signal = new EmaStep(signalLength);
500
+ }
501
+ step(value) {
502
+ const line = this.fast.step(value) - this.slow.step(value);
503
+ const signal = this.signal.step(line);
504
+ return [line, signal, line - signal];
505
+ }
506
+ commit() {
507
+ this.fast.commit();
508
+ this.slow.commit();
509
+ this.signal.commit();
510
+ }
511
+ }
512
+ class BbStep {
513
+ constructor(length, mult) {
514
+ this.mult = mult;
515
+ (0, import_limits.checkSumLength)("ta.bb", length, 0);
516
+ this.len = Math.floor(length);
517
+ }
518
+ mult;
519
+ basis = new SumStep();
520
+ dev = new StdevStep();
521
+ len;
522
+ step(value) {
523
+ const basis = this.basis.step(value, this.len) / this.len;
524
+ const dev = this.dev.step(value, this.len);
525
+ return [basis, basis + this.mult * dev, basis - this.mult * dev];
526
+ }
527
+ commit() {
528
+ this.basis.commit();
529
+ this.dev.commit();
530
+ }
531
+ }
532
+ class VwmaStep {
533
+ numerator = new SumStep();
534
+ denominator = new SumStep();
535
+ len;
536
+ constructor(length) {
537
+ (0, import_limits.checkPositiveLength)("vwma->sma", length, 0);
538
+ this.len = Math.floor(length);
539
+ }
540
+ step(value, volume) {
541
+ (0, import_limits.checkSumLength)("ta.sma", this.len, 0);
542
+ const num = this.numerator.step(value * volume, this.len) / this.len;
543
+ const den = this.denominator.step(volume, this.len) / this.len;
544
+ return den === 0 || Number.isNaN(den) ? NaN : num / den;
545
+ }
546
+ commit() {
547
+ this.numerator.commit();
548
+ this.denominator.commit();
549
+ }
550
+ }
551
+ class StochStep {
552
+ constructor(length) {
553
+ this.length = length;
554
+ (0, import_limits.checkPositiveLength)("stoch->highest", length, 0);
555
+ }
556
+ length;
557
+ highest = new HighestStep();
558
+ lowest = new LowestStep();
559
+ previous = NaN;
560
+ next = NaN;
561
+ stepped = false;
562
+ step(source, high, low) {
563
+ this.stepped = true;
564
+ const lo = this.lowest.step(low, this.length);
565
+ const k = 100 * (source - lo) / (this.highest.step(high, this.length) - lo);
566
+ this.next = Number.isNaN(k) ? this.previous : k;
567
+ return this.next;
568
+ }
569
+ commit() {
570
+ if (!this.stepped) return;
571
+ this.stepped = false;
572
+ this.previous = this.next;
573
+ this.highest.commit();
574
+ this.lowest.commit();
575
+ }
576
+ }
577
+ class HmaStep {
578
+ constructor(length) {
579
+ this.length = length;
580
+ (0, import_limits.checkPositiveLength)("hma", length, 0);
581
+ this.halfLength = Math.floor(length / 2);
582
+ this.sqrtLength = Math.floor(Math.sqrt(length));
583
+ }
584
+ length;
585
+ half = new WmaStep();
586
+ full = new WmaStep();
587
+ outer = new WmaStep();
588
+ halfLength;
589
+ sqrtLength;
590
+ step(value) {
591
+ const diff = 2 * this.half.step(value, this.halfLength) - this.full.step(value, this.length);
592
+ return this.outer.step(diff, this.sqrtLength);
593
+ }
594
+ commit() {
595
+ this.half.commit();
596
+ this.full.commit();
597
+ this.outer.commit();
598
+ }
599
+ }
600
+ class DevStep extends HistoryStep {
601
+ mean = new SmaStep();
602
+ len;
603
+ constructor(length) {
604
+ super();
605
+ (0, import_limits.checkPositiveLength)("dev", length, 0);
606
+ this.len = Math.floor(length);
607
+ }
608
+ step(value) {
609
+ this.keep(value);
610
+ const mean = this.mean.step(value, this.len);
611
+ if (this.history.length < this.len - 1 || Number.isNaN(mean)) return NaN;
612
+ let sum = 0;
613
+ for (let k = 0; k < this.len; k++) sum += Math.abs((k === 0 ? value : this.back(k)) - mean);
614
+ return sum / this.len;
615
+ }
616
+ commit() {
617
+ super.commit();
618
+ this.mean.commit();
619
+ }
620
+ }
621
+ class CciStep {
622
+ constructor(length) {
623
+ this.length = length;
624
+ (0, import_limits.checkPositiveLength)("cci", length, 0);
625
+ this.dev = new DevStep(length);
626
+ }
627
+ length;
628
+ mean = new SmaStep();
629
+ dev;
630
+ last = 0;
631
+ next = 0;
632
+ stepped = false;
633
+ step(value) {
634
+ this.stepped = true;
635
+ this.next = this.last;
636
+ const mean = this.mean.step(value, this.length);
637
+ const d = this.dev.step(value);
638
+ if (Number.isNaN(mean) || Number.isNaN(d)) return NaN;
639
+ if (!(0, import_compare.eq)(d, 0)) this.next = (value - mean) / (0.015 * d);
640
+ return this.next;
641
+ }
642
+ commit() {
643
+ if (this.stepped) this.last = this.next;
644
+ this.stepped = false;
645
+ this.mean.commit();
646
+ this.dev.commit();
647
+ }
648
+ }
649
+ class MfiStep extends HistoryStep {
650
+ constructor(length) {
651
+ super();
652
+ this.length = length;
653
+ (0, import_limits.checkPositiveLength)("mfi", length, 0);
654
+ }
655
+ length;
656
+ upper = new SumStep();
657
+ lower = new SumStep();
658
+ step(value, volume) {
659
+ this.keep(value);
660
+ const change = this.history.length === 0 ? NaN : value - this.back(1);
661
+ const flow = volume * value;
662
+ const zero = (x) => Math.abs(x) <= 1e-10 ? 0 : x;
663
+ const u = zero(this.upper.step((0, import_compare.le)(change, 0) ? 0 : flow, this.length));
664
+ const l = zero(this.lower.step((0, import_compare.ge)(change, 0) ? 0 : flow, this.length));
665
+ if (Number.isNaN(u) || Number.isNaN(l)) return NaN;
666
+ if (l === 0) return 100;
667
+ const ratio = 1 + u / l;
668
+ return ratio === 0 ? NaN : 100 - 100 / ratio;
669
+ }
670
+ commit() {
671
+ super.commit();
672
+ this.upper.commit();
673
+ this.lower.commit();
674
+ }
675
+ }
676
+ class DmiStep {
677
+ tr = new TrStep(false);
678
+ trur;
679
+ plus;
680
+ minus;
681
+ adx;
682
+ prevHigh = NaN;
683
+ prevLow = NaN;
684
+ bars = 0;
685
+ lastPlus = NaN;
686
+ lastMinus = NaN;
687
+ next = [NaN, NaN, NaN, NaN];
688
+ stepped = false;
689
+ constructor(diLength, adxSmoothing) {
690
+ this.trur = new RmaStep(diLength);
691
+ this.plus = new RmaStep(diLength);
692
+ this.minus = new RmaStep(diLength);
693
+ this.adx = new RmaStep(adxSmoothing);
694
+ }
695
+ step(high, low, close) {
696
+ this.stepped = true;
697
+ const up = this.bars === 0 ? NaN : high - this.prevHigh;
698
+ const down = this.bars === 0 ? NaN : this.prevLow - low;
699
+ const plusDM = Number.isNaN(up) ? NaN : (0, import_compare.gt)(up, down) && (0, import_compare.gt)(up, 0) ? up : 0;
700
+ const minusDM = Number.isNaN(down) ? NaN : (0, import_compare.gt)(down, up) && (0, import_compare.gt)(down, 0) ? down : 0;
701
+ const t = this.trur.step(this.tr.step(high, low, close));
702
+ const directional = (v, last) => {
703
+ const value = t === 0 ? NaN : 100 * v / t;
704
+ return Number.isNaN(value) ? last : value;
705
+ };
706
+ const plus = directional(this.plus.step(plusDM), this.lastPlus);
707
+ const minus = directional(this.minus.step(minusDM), this.lastMinus);
708
+ const sum = plus + minus;
709
+ const dx = Math.abs(plus - minus) / ((0, import_compare.eq)(sum, 0) ? 1 : sum);
710
+ const adx = 100 * this.adx.step(dx);
711
+ this.next = [plus, minus, high, low];
712
+ return [plus, minus, adx];
713
+ }
714
+ commit() {
715
+ if (!this.stepped) return;
716
+ this.stepped = false;
717
+ [this.lastPlus, this.lastMinus, this.prevHigh, this.prevLow] = this.next;
718
+ this.bars++;
719
+ this.tr.commit();
720
+ this.trur.commit();
721
+ this.plus.commit();
722
+ this.minus.commit();
723
+ this.adx.commit();
724
+ }
725
+ }
726
+ class LinregStep extends HistoryStep {
727
+ constructor(length, offset = 0) {
728
+ super();
729
+ this.offset = offset;
730
+ (0, import_limits.checkPositiveLength)("linreg", length, 0);
731
+ this.len = Math.floor(length);
732
+ }
733
+ offset;
734
+ len;
735
+ step(value) {
736
+ this.keep(value);
737
+ const len = this.len;
738
+ if (this.history.length < len - 1) return NaN;
739
+ const at = (j) => j === len - 1 ? value : this.back(len - 1 - j);
740
+ for (let j = 0; j < len; j++) if (isNaN(at(j))) return NaN;
741
+ let sumX = 0;
742
+ let sumY = 0;
743
+ let sumXY = 0;
744
+ let sumX2 = 0;
745
+ for (let j = 0; j < len; j++) {
746
+ const x = j + 1;
747
+ const y = at(j);
748
+ sumX += x;
749
+ sumY += y;
750
+ sumXY += x * y;
751
+ sumX2 += x * x;
752
+ }
753
+ const slope = (len * sumXY - sumX * sumY) / (len * sumX2 - sumX * sumX);
754
+ const intercept = sumY / len - slope * sumX / len + slope;
755
+ return intercept + slope * (len - 1 - this.offset);
756
+ }
757
+ }
758
+ class PercentrankStep extends HistoryStep {
759
+ constructor(length) {
760
+ super();
761
+ this.length = length;
762
+ (0, import_limits.checkPositiveLength)("percentrank", length, 0);
763
+ }
764
+ length;
765
+ step(value) {
766
+ this.keep(value);
767
+ if (this.history.length < this.length) return NaN;
768
+ let count = 0;
769
+ for (let j = 1; j <= this.length; j++) if ((0, import_compare.le)(this.back(j), value)) count++;
770
+ return count * 100 / this.length;
771
+ }
772
+ }
773
+ class MedianStep {
774
+ sorted = [];
775
+ kept = [];
776
+ nextSorted = null;
777
+ nextValue = null;
778
+ stepped = false;
779
+ len;
780
+ constructor(length) {
781
+ (0, import_limits.checkPositiveLength)("median", length, 0);
782
+ this.len = Math.floor(length);
783
+ }
784
+ static bound(sorted, v, after) {
785
+ let lo = 0;
786
+ let hi = sorted.length;
787
+ while (lo < hi) {
788
+ const m = lo + hi >> 1;
789
+ if (after ? sorted[m] <= v : sorted[m] < v) lo = m + 1;
790
+ else hi = m;
791
+ }
792
+ return lo;
793
+ }
794
+ step(value) {
795
+ this.stepped = true;
796
+ const len = this.len;
797
+ let sorted = this.sorted;
798
+ let count = this.kept.length;
799
+ this.nextValue = null;
800
+ this.nextSorted = null;
801
+ if (Number.isFinite(value)) {
802
+ sorted = sorted.slice();
803
+ count++;
804
+ sorted.splice(MedianStep.bound(sorted, value, false), 0, value);
805
+ if (count > len) {
806
+ const k = count - 1 - len;
807
+ const leaving = k === this.kept.length ? value : this.kept[k];
808
+ sorted.splice(MedianStep.bound(sorted, leaving, true) - 1, 1);
809
+ }
810
+ this.nextValue = value;
811
+ this.nextSorted = sorted;
812
+ }
813
+ if (!(len >= 1) || count < len) return NaN;
814
+ const mid = Math.floor(len / 2);
815
+ return len % 2 === 0 ? (sorted[mid - 1] + sorted[mid]) / 2 : sorted[mid];
816
+ }
817
+ commit() {
818
+ if (!this.stepped) return;
819
+ this.stepped = false;
820
+ if (this.nextValue !== null) {
821
+ this.kept.push(this.nextValue);
822
+ this.sorted = this.nextSorted;
823
+ }
824
+ }
825
+ }
826
+ class CorrelationStep {
827
+ constructor(length) {
828
+ this.length = length;
829
+ (0, import_limits.checkPositiveLength)("correlation", length, 0);
830
+ }
831
+ length;
832
+ meanXY = new SmaStep();
833
+ meanX = new SmaStep();
834
+ meanY = new SmaStep();
835
+ varX = new VarianceStep();
836
+ varY = new VarianceStep();
837
+ step(a, b) {
838
+ const product = a === null || a === void 0 || b === null || b === void 0 ? NaN : a * b;
839
+ const mxy = this.meanXY.step(product, this.length);
840
+ const cov = mxy - this.meanX.step(a, this.length) * this.meanY.step(b, this.length);
841
+ const vx = this.varX.step(a, this.length);
842
+ const vy = this.varY.step(b, this.length);
843
+ if (Number.isNaN(cov)) return NaN;
844
+ if (Math.abs(cov) <= 1e-10) return 0;
845
+ const denominator = Math.sqrt(vx * vy);
846
+ return denominator === 0 ? NaN : cov / denominator;
847
+ }
848
+ commit() {
849
+ this.meanXY.commit();
850
+ this.meanX.commit();
851
+ this.meanY.commit();
852
+ this.varX.commit();
853
+ this.varY.commit();
854
+ }
855
+ }
856
+ class WprStep {
857
+ constructor(length = 14) {
858
+ this.length = length;
859
+ (0, import_limits.checkPositiveLength)("wpr", length, 0);
860
+ }
861
+ length;
862
+ highest = new HighestStep();
863
+ lowest = new LowestStep();
864
+ step(high, low, close) {
865
+ const hmax = this.highest.step(high, this.length);
866
+ const range = hmax - this.lowest.step(low, this.length);
867
+ return range === 0 ? NaN : 100 * (close - hmax) / range;
868
+ }
869
+ commit() {
870
+ this.highest.commit();
871
+ this.lowest.commit();
872
+ }
873
+ }
874
+ class SupertrendStep {
875
+ constructor(factor, atrPeriod, wicks = false) {
876
+ this.factor = factor;
877
+ this.wicks = wicks;
878
+ this.atr = new AtrStep(atrPeriod);
879
+ }
880
+ factor;
881
+ wicks;
882
+ atr;
883
+ lastLower = NaN;
884
+ lastUpper = NaN;
885
+ prevSuperTrend = NaN;
886
+ prevAtr = NaN;
887
+ prevHigh = NaN;
888
+ prevLow = NaN;
889
+ bars = 0;
890
+ next = [NaN, NaN, NaN, NaN, NaN, NaN];
891
+ stepped = false;
892
+ step(high, low, close) {
893
+ this.stepped = true;
894
+ const nz = (v) => isNaN(v) ? 0 : v;
895
+ const source = (high + low) / 2;
896
+ const atr = this.atr.step(high, low, close);
897
+ const atrValue = atr * this.factor;
898
+ let upperBand = source + atrValue;
899
+ let lowerBand = source - atrValue;
900
+ const prevLowerBand = nz(this.lastLower);
901
+ const prevUpperBand = nz(this.lastUpper);
902
+ const highPrice = this.wicks ? high : close;
903
+ const lowPrice = this.wicks ? low : close;
904
+ const prevLowPrice = this.bars > 0 ? this.prevLow : NaN;
905
+ const prevHighPrice = this.bars > 0 ? this.prevHigh : NaN;
906
+ lowerBand = lowerBand > prevLowerBand || prevLowPrice < prevLowerBand ? lowerBand : prevLowerBand;
907
+ upperBand = upperBand < prevUpperBand || prevHighPrice > prevUpperBand ? upperBand : prevUpperBand;
908
+ let direction;
909
+ if (this.bars === 0 || isNaN(this.prevAtr)) direction = 1;
910
+ else if (this.prevSuperTrend === prevUpperBand) direction = highPrice > upperBand ? -1 : 1;
911
+ else direction = lowPrice < lowerBand ? 1 : -1;
912
+ const superTrend = direction === -1 ? lowerBand : upperBand;
913
+ this.next = [lowerBand, upperBand, superTrend, atr, highPrice, lowPrice];
914
+ return [superTrend, direction];
915
+ }
916
+ commit() {
917
+ if (!this.stepped) return;
918
+ this.stepped = false;
919
+ [this.lastLower, this.lastUpper, this.prevSuperTrend, this.prevAtr, this.prevHigh, this.prevLow] = this.next;
920
+ this.bars++;
921
+ this.atr.commit();
922
+ }
923
+ }
924
+ const taStep = {
925
+ /** `math.sum(source, length)`: step(value, length) */
926
+ sum: () => new SumStep(),
927
+ /** `ta.sma(source, length)`: step(value, length) */
928
+ sma: () => new SmaStep(),
929
+ /** `ta.variance(source, length, biased)`: step(value, length, biased?) */
930
+ variance: () => new VarianceStep(),
931
+ /** `ta.stdev(source, length, biased)`: step(value, length, biased?) */
932
+ stdev: () => new StdevStep(),
933
+ /** `ta.ema(source, length)`: step(value) */
934
+ ema: (length) => new EmaStep(length),
935
+ /** `ta.rma(source, length)`: step(value) */
936
+ rma: (length) => new RmaStep(length),
937
+ /** `ta.wma(source, length)`: step(value, length) */
938
+ wma: () => new WmaStep(),
939
+ /** `ta.change(source, length)`: step(value) */
940
+ change: (length = 1) => new ChangeStep(length),
941
+ /** `ta.mom(source, length)`: step(value) */
942
+ mom: (length) => new MomStep(length),
943
+ /** `ta.roc(source, length)`: step(value) */
944
+ roc: (length) => new RocStep(length),
945
+ /** `ta.tr(handle_na)`: step(high, low, close) */
946
+ tr: (handle_na = false) => new TrStep(handle_na),
947
+ /** `ta.atr(length)`: step(high, low, close) */
948
+ atr: (length) => new AtrStep(length),
949
+ /** `ta.rsi(source, length)`: step(value) */
950
+ rsi: (length) => new RsiStep(length),
951
+ /** `ta.cum(source)`: step(value) */
952
+ cum: () => new CumStep(),
953
+ /** `ta.crossover(a, b)`: step(a, b) */
954
+ crossover: () => new CrossoverStep(),
955
+ /** `ta.crossunder(a, b)`: step(a, b) */
956
+ crossunder: () => new CrossunderStep(),
957
+ /** `ta.cross(a, b)`: step(a, b) */
958
+ cross: () => new CrossStep(),
959
+ /** `ta.barssince(condition)`: step(condition) */
960
+ barssince: () => new BarssinceStep(),
961
+ /** `ta.valuewhen(condition, source, occurrence)`: step(condition, value) */
962
+ valuewhen: (occurrence) => new ValuewhenStep(occurrence),
963
+ /** `ta.obv`: step(close, volume) */
964
+ obv: () => new ObvStep(),
965
+ /** `ta.highest(source, length)`: step(value, length) */
966
+ highest: () => new HighestStep(),
967
+ /** `ta.lowest(source, length)`: step(value, length) */
968
+ lowest: () => new LowestStep(),
969
+ /** `ta.macd(source, fast, slow, signal)`: step(value) gives [macd, signal, histogram] */
970
+ macd: (fastLength, slowLength, signalLength) => new MacdStep(fastLength, slowLength, signalLength),
971
+ /** `ta.bb(source, length, mult)`: step(value) gives [basis, upper, lower] */
972
+ bb: (length, mult) => new BbStep(length, mult),
973
+ /** `ta.vwma(source, length)`: step(value, volume) */
974
+ vwma: (length) => new VwmaStep(length),
975
+ /** `ta.stoch(source, high, low, length)`: step(source, high, low) */
976
+ stoch: (length) => new StochStep(length),
977
+ /** `ta.hma(source, length)`: step(value) */
978
+ hma: (length) => new HmaStep(length),
979
+ /** `ta.dev(source, length)`: step(value) */
980
+ dev: (length) => new DevStep(length),
981
+ /** `ta.cci(source, length)`: step(value) */
982
+ cci: (length) => new CciStep(length),
983
+ /** `ta.mfi(source, length)`: step(value, volume) */
984
+ mfi: (length) => new MfiStep(length),
985
+ /** `ta.dmi(diLength, adxSmoothing)`: step(high, low, close) gives [plus, minus, adx] */
986
+ dmi: (diLength, adxSmoothing) => new DmiStep(diLength, adxSmoothing),
987
+ /** `ta.linreg(source, length, offset)`: step(value), called on every bar (in an if block: callsite.linreg) */
988
+ linreg: (length, offset = 0) => new LinregStep(length, offset),
989
+ /** `ta.percentrank(source, length)`: step(value) */
990
+ percentrank: (length) => new PercentrankStep(length),
991
+ /** `ta.median(source, length)`: step(value) */
992
+ median: (length) => new MedianStep(length),
993
+ /** `ta.correlation(source1, source2, length)`: step(a, b) */
994
+ correlation: (length) => new CorrelationStep(length),
995
+ /** `ta.wpr(length)`: step(high, low, close) */
996
+ wpr: (length = 14) => new WprStep(length),
997
+ /** `ta.supertrend(factor, atrPeriod)`: step(high, low, close) gives [supertrend, direction] */
998
+ supertrend: (factor, atrPeriod) => new SupertrendStep(factor, atrPeriod)
999
+ };
1000
+ //# sourceMappingURL=step.js.map