-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.ts
648 lines (538 loc) · 25.9 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
import {Series} from "numbers.ts";
export class TALib {
public static sma(value: (number | null)[] | undefined, period: number): {sma: Series} {
return {sma: new Series(value).simpleMovingAverage(period)};
}
public static ema(value: (number | null)[] | undefined, period: number, smoothing: number): {ema: Series} {
return {ema: new Series(value).exponentialMovingAverage(period, smoothing)};
}
public static dema(value: (number | null)[] | undefined, period: number, smoothing: number): {dema: Series} {
let ema = new Series(value).exponentialMovingAverage(period, smoothing);
return {dema: ema.multiply(2).subtract(ema.exponentialMovingAverage(period, smoothing))};
}
/**
* Modified moving average
* @param value
* @param period
*/
public static mma(value: (number | null)[] | undefined, period: number): {mma: Series} {
return {mma: new Series(value).modifiedMovingAverage(period)};
}
public static wsma(value: (number | null)[] | undefined, weight: (number | null)[] | undefined, period: number):{mma: Series} {
return {mma: new Series(value).weightedSimpleMovingAverage(new Series(weight), period)};
}
public static wema(value: (number | null)[] | undefined, weight: (number | null)[] | undefined, period: number, smoothing: number):{wema: Series} {
return {wema: new Series(value).weightedExponentialMovingAverage(new Series(weight), period, smoothing)};
}
public static distance(value1: (number | null)[] | undefined, value2: (number | null)[] | undefined | number):{distance: Series} {
if(typeof value2 == 'number') return {distance: new Series(value1).distance(value2)};
else return {distance: new Series(value1).distance(new Series(value2))};
}
public static subtract(value1: (number | null)[] | undefined, value2: (number | null)[] | undefined | number):{subtract: Series} {
if(typeof value2 == 'number') return {subtract: new Series(value1).subtract(value2)};
else return {subtract: new Series(value1).subtract(new Series(value2))};
}
public static add(value1: (number | null)[] | undefined, value2: (number | null)[] | undefined | number):{add: Series} {
if(typeof value2 == 'number') return {add: new Series(value1).add(value2)};
else return {add: new Series(value1).add(new Series(value2))};
}
public static modulo(value1: (number | null)[] | undefined, value2: (number | null)[] | undefined | number):{modulo: Series} {
if(typeof value2 == 'number') return {modulo: new Series(value1).modulo(value2)};
else return {modulo: new Series(value1).modulo(new Series(value2))};
}
public static multiply(value1: (number | null)[] | undefined, value2: (number | null)[] | undefined | number):{multiply: Series} {
if(typeof value2 == 'number') return {multiply: new Series(value1).multiply(value2)};
else return {multiply: new Series(value1).multiply(new Series(value2))};
}
public static divide(value1: (number | null)[] | undefined, value2: (number | null)[] | undefined | number):{divide: Series} {
if(typeof value2 == 'number') return {divide: new Series(value1).divide(value2)};
else return {divide: new Series(value1).divide(new Series(value2))};
}
public static stdDev(value: (number | null)[] | undefined, average: (number | null)[] | undefined | number, period: number): {stdDev: Series} {
if(typeof average == 'number') return {stdDev: new Series(value).stdDev(average, period)};
else return {stdDev: new Series(value).stdDev(new Series(average), period)};
}
/**
* Variance
* @param value
* @param average
* @param period
*/
public static var(value: (number | null)[] | undefined, average: (number | null)[] | undefined, period: number): {var: Series} {
if(typeof average == 'number') return {var: new Series(value).variance(average, period)};
else return {var: new Series(value).variance(new Series(average), period)};
}
public static macdDefault = {fastPeriod: 12, slowPeriod: 26, signalPeriod: 9};
public static macd(close: (number | null)[] | undefined, fastPeriod: number, slowPeriod: number, signalPeriod: number): { macd: Series, macdSignal: Series, macdHist: Series } {
let series = new Series(close);
if (fastPeriod <= 0) throw Error("Fast period must be a positive integer.");
if (slowPeriod <= 0) throw Error("Slow period must be a positive integer.");
if (signalPeriod <= 0) throw Error("Signal period must be a positive integer.");
if (slowPeriod <= fastPeriod) throw Error("Slow period must be longer than fast period.");
let fast = series.exponentialMovingAverage(fastPeriod, 2);
let slow = series.exponentialMovingAverage(slowPeriod, 2);
let macd = fast.subtract(slow);
let signal = macd.exponentialMovingAverage(signalPeriod, 2);
let hist = macd.subtract(signal);
return {
macd: macd,
macdSignal: signal,
macdHist: hist
}
}
public avgPrice(open: (number | null)[] | undefined, high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined): {avgPrice: Series} {
if (open == undefined) throw Error("Missing open.");
if (high == undefined) throw Error("Missing high.");
if (low == undefined) throw Error("Missing low.");
if (close == undefined) throw Error("Missing close.");
if (open.length != high.length) throw Error("Open and high must have the same length.");
if (open.length != low.length) throw Error("Open and low must have the same length.");
if (open.length != close.length) throw Error("Open and close must have the same length.");
return {avgPrice: new Series(open).add(new Series(high)).add(new Series(low)).add(new Series(close)).divide(4)};
}
/**
* Balance Of Power
* @param open
* @param high
* @param low
* @param close
*/
public static bop(open: (number | null)[] | undefined,high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined, period: number): {bop: Series} {
if (open == undefined) throw Error("Missing open.");
if (high == undefined) throw Error("Missing high.");
if (low == undefined) throw Error("Missing low.");
if (close == undefined) throw Error("Missing close.");
if (period <= 0 || !Number.isInteger(period)) throw Error("Fast period must be a positive integer.");
return {bop: new Series(close).subtract(new Series(open)).divide(new Series(high).subtract(new Series(low))).simpleMovingAverage(period)}
}
public static bopDefault = {
period: 14
}
/**
* Commodity Channel Index
* @param high
* @param low
* @param close
* @param period
*/
public static cci(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined, period: number): {cci: Series} {
if (high == undefined) throw Error("Missing high.");
if (low == undefined) throw Error("Missing low.");
if (close == undefined) throw Error("Missing close.");
if (period <= 0 || !Number.isInteger(period)) throw Error("Fast period must be a positive integer.");
let tp = this.typPrice(high, low, close).typPrice;
let ma = tp.simpleMovingAverage(period);
return {cci: tp.subtract(ma).divide(0.015).divide(tp.meanDev(ma, period))}
}
public static cciDefault = {
period: 14
}
public static bbandsDefault = {
period: 5,
bandWidth: 2,
}
public static bbands(close: (number | null)[] | undefined, period: number, bandWidth: number): {bbandsLower: Series; bbandsSma: Series; bbandsUpper: Series;} {
if (close == undefined) throw Error("Missing close.");
if (period <= 0) throw Error("Fast period must be a positive integer.");
let c = new Series(close);
let sma = c.simpleMovingAverage(period);
let dev = c.stdDev(sma, period).multiply(bandWidth);
let upper = sma.add(dev);
let lower = sma.subtract(dev);
return {
bbandsLower: lower,
bbandsSma: sma,
bbandsUpper: upper,
}
}
/**
* Typical Price
* @param high
* @param low
* @param close
* @constructor
*/
public static typPrice(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined): {typPrice: Series} {
if (high == undefined) throw Error("Missing high.");
if (low == undefined) throw Error("Missing low.");
if (close == undefined) throw Error("Missing close.");
if (high.length != low.length) throw Error("High and low must have the same length.");
if (high.length != close.length) throw Error("High and close must have the same length.");
return {typPrice: new Series(high).add(new Series(low)).add(new Series(close)).divide(3)};
}
/**
* Weighted Close Price
* @param high
* @param low
* @param close
*/
public static wClPrice(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined): {wClPrice: Series} {
if (high == undefined) throw Error("Missing high.");
if (low == undefined) throw Error("Missing low.");
if (close == undefined) throw Error("Missing close.");
if (high.length != low.length) throw Error("High and low must have the same length.");
if (high.length != close.length) throw Error("High and close must have the same length.");
return { wClPrice: new Series(high).add(new Series(low)).add(new Series(close).multiply(2)).divide(4)};
}
/**
* Volume-Weighted Average Price
* @param close
* @param volume
* @param period
*/
public static vwap(close: (number | null)[] | undefined, volume: (number | null)[] | undefined, period: number): {vwap: Series} {
return {vwap: new Series(close).weightedSimpleMovingAverage(new Series(volume), period)};
}
/**
* Volume-Weighted Exponential Average Price
* @param close
* @param volume
* @param period
*/
public static vweap(close: (number | null)[] | undefined, volume: (number | null)[] | undefined, period: number, smoothing: number): {vweap: Series} {
return {vweap: new Series(close).weightedExponentialMovingAverage(new Series(volume), period, smoothing)};
}
/**
* True Range
* https://www.investopedia.com/terms/a/atr.asp
* @param high
* @param low
* @param close
*/
public static tRange(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined): {tRange: Series} {
if (high == undefined) throw Error("Missing high value.");
if (low == undefined) throw Error("Missing low value.");
if (close == undefined) throw Error("Missing close average.");
if (high.length != low.length) throw Error("High and low must have the same length.");
if (high.length != close.length) throw Error("High and close must have the same length.");
let c = new Series(close).lag(1);
let h = new Series(high);
let l = new Series(low);
return{tRange: h.subtract(l).max(h.distance(c)).max(l.distance(c))};
}
/**
* Average True Range
* https://www.investopedia.com/terms/a/atr.asp
*
* @param high
* @param low
* @param close
* @param period
*/
public static atr(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined, period: number): {atr: Series} {
return {atr: this.tRange(high, low, close).tRange.modifiedMovingAverage(period)};
}
public static atrDefault = {"period": 14};
/**
* Money Flow Index
* @param high
* @param low
* @param close
* @param volume
* @param period
*/
public static mfi(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined, volume: (number | null)[] | undefined, period: number): {mfi: Series} {
let tp = this.typPrice(high, low, close).typPrice;
let mf = tp.multiply(new Series(volume));
let diff = tp.subtract(tp.lag(1));
return {mfi: diff.greaterThan(0).multiply(mf).simpleMovingAverage(period).divide(diff.lessThan(0).multiply(mf).simpleMovingAverage(period)).subtract(1).power(-1).multiply(100).add(100)};
}
public static mfiDefault = {"period": 14};
/**
* Chande Momentum Oscillator
* @param close
* @param period
*/
public static cmo(close: (number | null)[] | undefined, period: number): {cmo: Series} {
let diff = new Series(close).subtract(new Series(close).lag(1));
let up = diff.greaterThan(0).multiply(diff).simpleMovingAverage(period);
let down = diff.lessThan(0).multiply(diff).simpleMovingAverage(period);
return {cmo: up.add(down).divide(up.subtract(down)).multiply(100)};
}
public static cmoDefault = {"period": 14};
/**
* Chaikin A/D Line
* @param high
* @param low
* @param close
* @param volume
*/
public static ad(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined, volume: (number | null)[] | undefined): {ad: Series} {
if (high == undefined) throw Error("Missing high value.");
if (low == undefined) throw Error("Missing low value.");
if (close == undefined) throw Error("Missing close average.");
if (volume == undefined) throw Error("Missing volume average.");
if (high.length != low.length) throw Error("High and low must have the same length.");
if (high.length != close.length) throw Error("High and close must have the same length.");
if (high.length != volume.length) throw Error("High and volume must have the same length.");
let h = new Series(high);
let l = new Series(low);
let c = new Series(close);
let v = new Series(volume);
return {ad: v.multiply(c.subtract(l).subtract(h.subtract(c)).divide(h.subtract(l)).fillError(0)).carry()};
}
/**
* Chaikin A/D Oscillator
* https://www.investopedia.com/terms/c/chaikinoscillator.asp#:~:text=To%20calculate%20the%20Chaikin%20oscillator,around%20the%20accumulation%2Ddistribution%20line.
* @param high
* @param low
* @param close
* @param volume
* @param fastPeriod
* @param slowPeriod
*/
public static adOsc(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined, volume: (number | null)[] | undefined, fastPeriod: number, slowPeriod: number): {adOsc: Series} {
let ad = this.ad(high, low, close, volume).ad;
return {adOsc: ad.exponentialMovingAverage(fastPeriod, 2).subtract(ad.exponentialMovingAverage(slowPeriod, 2))}
}
public static adOscDefault = {fastPeriod: 3, slowPeriod: 10};
/**
* Average Directional Movement Index
* @param high
* @param low
* @param close
* @param period
*/
public static adx(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined, period: number): {adx: Series} {
return{adx: this.dx(high, low, close, period).dx.modifiedMovingAverage(period)};
}
public static adxDefault = {period: 14};
/**
* Average Directional Movement Index Rating
* https://www.daytrading.com/adx-adxr
* @param high
* @param low
* @param close
* @param lagPeriod
* @param adxPeriod: period used to calulate adx
*/
public static adxr(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined, lagPeriod: number, adxPeriod: number): {adxr: Series} {
if(lagPeriod<0) throw Error("Period must be greater than 0.")
let adx = this.adx(high, low, close, adxPeriod);
return {adxr: adx.adx.add(adx.adx.lag(lagPeriod)).divide(2)};
}
public static adxrDefault = {lagPeriod: 10, adxPeriod: 14};
/**
* Absolute Price Oscillator
* @param close
* @param fastPeriod
* @param slowPeriod
*/
public static apo(close: (number | null)[] | undefined, fastPeriod: number, slowPeriod: number): { apo: Series } {
if (close == undefined) throw Error("Missing close.");
if (fastPeriod <= 0) throw Error("Fast period must be a positive integer.");
if (slowPeriod <= 0) throw Error("Slow period must be a positive integer.");
if (slowPeriod <= fastPeriod) throw Error("Slow period must be longer than fast period.");
let c = new Series(close);
return {apo: c.exponentialMovingAverage(slowPeriod, 2).subtract(c.exponentialMovingAverage(fastPeriod, 2))};
}
public static apoDefault = {fastPeriod: 12, slowPeriod: 26, signalPeriod: 9};
public static aroon(high: (number | null)[] | undefined, low: (number | null)[] | undefined, period: number): {'aroonUp':Series, 'aroonDown':Series} {
if (high == undefined) throw Error("Missing high.");
if (low == undefined) throw Error("Missing low.");
if (period <= 0 || !Number.isInteger(period)) throw Error("Period must be a positive integer.");
return {
aroonUp: new Series(high).movingMaxDistance(period).divide(period).subtract(1).absolute(),
aroonDown: new Series(low).movingMinDistance(period).divide(period).subtract(1).absolute()
};
}
public static aroonDefault = {period: 25};
public static aroonOsc (high: (number | null)[] | undefined, low: (number | null)[] | undefined, period: number): {'aroonOsc':Series} {
let aroon = this.aroon(high, low, period);
return {aroonOsc: aroon.aroonUp.subtract(aroon.aroonDown)}
}
public static aroonOscDefault = {period: 25};
/**
* Directional Movement
* @param high
* @param low
*/
public static dm(high: (number | null)[] | undefined, low: (number | null)[] | undefined): {pdm: Series, ndm: Series} {
if (high == undefined) throw Error("Missing high value.");
if (low == undefined) throw Error("Missing low value.");
if (high.length != low.length) throw Error("High and low must have the same length.");
let h = new Series(high);
let l = new Series(low);
let up = h.subtract(h.lag(1));
let down = l.lag(1).subtract(l);
return {
pdm: up.greaterThan(down).and(up.greaterThan(0)).multiply(up),
ndm: down.greaterThan(up).and(down.greaterThan(0)).multiply(down)
};
}
/**
* Directional Index
* https://www.investopedia.com/terms/a/adx.asp#:~:text=To%20get%20the%20ADX%2C%20continue,%2B%20current%20DX)%20%2F%2014.
* https://www.investopedia.com/terms/p/positivedirectionalindicator.asp
* https://en.wikipedia.org/wiki/Average_directional_movement_index
* @param high
* @param low
* @param close
* @param period
*/
public static di(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined, period: number): {pdi: Series, ndi: Series} {
let atr =this.tRange(high, low, close).tRange.modifiedMovingAverage(period);
let dm = this.dm(high, low);
return {
pdi: dm.pdm.modifiedMovingAverage(period).divide(atr).multiply(100),
ndi: dm.ndm.modifiedMovingAverage(period).divide(atr).multiply(100)
};
}
public static diDefault = {period: 14};
/**
* Directional Index
* https://www.investopedia.com/terms/a/adx.asp#:~:text=To%20get%20the%20ADX%2C%20continue,%2B%20current%20DX)%20%2F%2014.
* https://www.investopedia.com/terms/p/positivedirectionalindicator.asp
* https://en.wikipedia.org/wiki/Average_directional_movement_index
* @param high
* @param low
* @param close
* @param period
*/
public static dx(high: (number | null)[] | undefined, low: (number | null)[] | undefined, close: (number | null)[] | undefined, period: number): {dx:Series} {
//let di = this.di(high, low, close, period);
let dm = this.dm(high, low);
let pdi = dm.pdm.modifiedMovingAverage(period);
let ndi = dm.ndm.modifiedMovingAverage(period);
return {dx: pdi.subtract(ndi).divide(pdi.add(ndi)).multiply(100)}
}
public static dxDefault = {period: 14};
/**
* Relative Strength Index
* @param close
* @param period
*/
public static rsi(close: (number | null)[] | undefined, period: number): {rsi: Series} {
let ret = new Series(close).divide(new Series(close)).subtract(1);
return {rsi: ret.greaterThan(0).multiply(ret).simpleMovingAverage(period).divide(ret.lessThan(0).multiply(ret).simpleMovingAverage(period)).subtract(1).power(-1).multiply(100).add(100)};
}
public static rsiDefault = {period: 14};
public static stochRsi(close: (number | null)[] | undefined, rsiPeriod: number, period: number): {stochRsi: Series} {
let rsi = this.rsi(close, rsiPeriod).rsi;
let min = rsi.movingMin(period);
return {stochRsi:rsi.subtract(min).divide(rsi.max(period).subtract(min))};
}
public static stochRsiDefault = {rsiPeriod: 14, period: 14};
/**
* Parabolic SAR
* @param high
* @param low
* @param af
* @param maxAf
*/
public static sar(high: (number | null)[], low: (number | null)[], af: number, maxAf:number): {rpsar: Series, fpsar: Series} {
let rpsar = new Series([]);
let fpsar= new Series([]);
let f = af;
let r = true;
let ep = 0;
let sar: number | null = null;
let first: number | null = null;
for(let i = 0; i<high.length; i++) {
if(high[i]!=null && high[i]!=null) {
if(first == null) {
first = i;
rpsar.push(null);
fpsar.push(null);
}
else if(sar==null) {
if((high[first] as number) +(low[first] as number)>(high[i] as number)+(low[i] as number)) {
r = false;
ep = Math.min((low[first] as number), (low[i] as number));
sar = Math.max((high[first] as number), (high[i] as number));
rpsar.push(null);
fpsar.push(sar);
}
else {
r = true;
ep = Math.max((high[first] as number), (high[i] as number));
sar = Math.min((low[first] as number), (low[i] as number));
fpsar.push(null);
rpsar.push(sar);
}
}
else {
sar+= f*(ep - sar);
if(r) {
if(high[i] as number>ep) {
f = Math.min(af+f, maxAf);
ep = high[i] as number;
}
if((low[i] as number)<=sar) {
r = false;
sar = ep;
ep = low[i] as number;
fpsar.push(sar);
rpsar.push(null);
f = af;
}
else {
rpsar.push(sar);
fpsar.push(null);
}
}
else {
if((low[i] as number) < ep) {
f = Math.min(af+f, maxAf);
ep = low[i] as number;
}
if((high[i] as number)>=sar) {
r = true;
sar = ep;
ep = high[i] as number;
rpsar.push(sar);
fpsar.push(null);
f = af;
}
else {
fpsar.push(sar);
rpsar.push(null);
}
}
}
}
else {
rpsar.push(null);
fpsar.push(null);
}
}
return {rpsar: rpsar, fpsar: fpsar}
}
public static sarDefault = {af: 0.02, maxAf: 0.2};
/**
* Highest value over a specified period
* @param value
* @param period
*/
public static movingMax(value: (number | null)[] | undefined, period:number): {movingMax: Series} {
if(value==undefined) throw Error("Value is missing.");
return {movingMax: new Series(value).movingMax(period)};
}
/**
* Index of highest value over a specified period
* @param value
* @param period
*/
public static movingMaxIndex(value: (number | null)[] | undefined, period:number): {movingMaxIndex: Series} {
if(value==undefined) throw Error("Value is missing.");
return {movingMaxIndex: new Series(value).movingMaxIndex(period)};
}
/**
* Lowest value over a specified period
* @param value
* @param period
*/
public static movingMin(value: (number | null)[] | undefined, period:number): {movingMin: Series} {
if(value==undefined) throw Error("Value is missing.");
return {movingMin: new Series(value).movingMin(period)};
}
/**
* Index of lowest value over a specified period
* @param value
* @param period
*/
public static movingMinIndex(value: (number | null)[] | undefined, period:number): {movingMinIndex: Series} {
if(value==undefined) throw Error("Value is missing.");
return {movingMinIndex: new Series(value).movingMinIndex(period)};
}
}