pinets 0.1.31 → 0.1.34

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.
@@ -2084,6 +2084,44 @@ class TechnicalAnalysis {
2084
2084
  const idx = this.context.idx;
2085
2085
  return [[this.context.precision(supertrend[idx]), direction[idx]]];
2086
2086
  }
2087
+ crossover(source1, source2) {
2088
+ const current1 = Array.isArray(source1) ? source1[0] : source1;
2089
+ const current2 = Array.isArray(source2) ? source2[0] : source2;
2090
+ const prev1 = Array.isArray(source1) ? source1[1] : this.context.data.series[source1][1];
2091
+ const prev2 = Array.isArray(source2) ? source2[1] : this.context.data.series[source2][1];
2092
+ return prev1 < prev2 && current1 > current2;
2093
+ }
2094
+ crossunder(source1, source2) {
2095
+ const current1 = Array.isArray(source1) ? source1[0] : source1;
2096
+ const current2 = Array.isArray(source2) ? source2[0] : source2;
2097
+ const prev1 = Array.isArray(source1) ? source1[1] : this.context.data.series[source1][1];
2098
+ const prev2 = Array.isArray(source2) ? source2[1] : this.context.data.series[source2][1];
2099
+ return prev1 > prev2 && current1 < current2;
2100
+ }
2101
+ pivothigh(source, _leftbars, _rightbars) {
2102
+ if (_rightbars == void 0) {
2103
+ _rightbars = _leftbars;
2104
+ _leftbars = source;
2105
+ source = this.context.data.high;
2106
+ }
2107
+ const leftbars = Array.isArray(_leftbars) ? _leftbars[0] : _leftbars;
2108
+ const rightbars = Array.isArray(_rightbars) ? _rightbars[0] : _rightbars;
2109
+ const result = pivothigh(source.slice(0).reverse(), leftbars, rightbars);
2110
+ const idx = this.context.idx;
2111
+ return this.context.precision(result[idx]);
2112
+ }
2113
+ pivotlow(source, _leftbars, _rightbars) {
2114
+ if (_rightbars == void 0) {
2115
+ _rightbars = _leftbars;
2116
+ _leftbars = source;
2117
+ source = this.context.data.low;
2118
+ }
2119
+ const leftbars = Array.isArray(_leftbars) ? _leftbars[0] : _leftbars;
2120
+ const rightbars = Array.isArray(_rightbars) ? _rightbars[0] : _rightbars;
2121
+ const result = pivotlow(source.slice(0).reverse(), leftbars, rightbars);
2122
+ const idx = this.context.idx;
2123
+ return this.context.precision(result[idx]);
2124
+ }
2087
2125
  }
2088
2126
  function atr(high, low, close, period) {
2089
2127
  const tr = new Array(high.length);
@@ -2423,6 +2461,56 @@ function calculateSupertrend(high, low, close, factor, atrPeriod) {
2423
2461
  }
2424
2462
  return [supertrend, direction];
2425
2463
  }
2464
+ function pivothigh(source, leftbars, rightbars) {
2465
+ const result = new Array(source.length).fill(NaN);
2466
+ for (let i = leftbars + rightbars; i < source.length; i++) {
2467
+ const pivot = source[i - rightbars];
2468
+ let isPivot = true;
2469
+ for (let j = 1; j <= leftbars; j++) {
2470
+ if (source[i - rightbars - j] >= pivot) {
2471
+ isPivot = false;
2472
+ break;
2473
+ }
2474
+ }
2475
+ if (isPivot) {
2476
+ for (let j = 1; j <= rightbars; j++) {
2477
+ if (source[i - rightbars + j] >= pivot) {
2478
+ isPivot = false;
2479
+ break;
2480
+ }
2481
+ }
2482
+ }
2483
+ if (isPivot) {
2484
+ result[i] = pivot;
2485
+ }
2486
+ }
2487
+ return result;
2488
+ }
2489
+ function pivotlow(source, leftbars, rightbars) {
2490
+ const result = new Array(source.length).fill(NaN);
2491
+ for (let i = leftbars + rightbars; i < source.length; i++) {
2492
+ const pivot = source[i - rightbars];
2493
+ let isPivot = true;
2494
+ for (let j = 1; j <= leftbars; j++) {
2495
+ if (source[i - rightbars - j] <= pivot) {
2496
+ isPivot = false;
2497
+ break;
2498
+ }
2499
+ }
2500
+ if (isPivot) {
2501
+ for (let j = 1; j <= rightbars; j++) {
2502
+ if (source[i - rightbars + j] <= pivot) {
2503
+ isPivot = false;
2504
+ break;
2505
+ }
2506
+ }
2507
+ }
2508
+ if (isPivot) {
2509
+ result[i] = pivot;
2510
+ }
2511
+ }
2512
+ return result;
2513
+ }
2426
2514
 
2427
2515
  var __defProp$2 = Object.defineProperty;
2428
2516
  var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;