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.
- package/dist/pinets.dev.browser.js +88 -0
- package/dist/pinets.dev.cjs +88 -0
- package/dist/pinets.dev.cjs.map +1 -1
- package/dist/pinets.dev.es.js +88 -0
- package/dist/pinets.dev.es.js.map +1 -1
- package/dist/pinets.min.browser.js +12 -12
- package/dist/pinets.min.cjs +12 -12
- package/dist/pinets.min.es.js +2 -2
- package/dist/types/namespaces/TechnicalAnalysis.d.ts +4 -0
- package/package.json +1 -1
|
@@ -9740,6 +9740,44 @@
|
|
|
9740
9740
|
const idx = this.context.idx;
|
|
9741
9741
|
return [[this.context.precision(supertrend[idx]), direction[idx]]];
|
|
9742
9742
|
}
|
|
9743
|
+
crossover(source1, source2) {
|
|
9744
|
+
const current1 = Array.isArray(source1) ? source1[0] : source1;
|
|
9745
|
+
const current2 = Array.isArray(source2) ? source2[0] : source2;
|
|
9746
|
+
const prev1 = Array.isArray(source1) ? source1[1] : this.context.data.series[source1][1];
|
|
9747
|
+
const prev2 = Array.isArray(source2) ? source2[1] : this.context.data.series[source2][1];
|
|
9748
|
+
return prev1 < prev2 && current1 > current2;
|
|
9749
|
+
}
|
|
9750
|
+
crossunder(source1, source2) {
|
|
9751
|
+
const current1 = Array.isArray(source1) ? source1[0] : source1;
|
|
9752
|
+
const current2 = Array.isArray(source2) ? source2[0] : source2;
|
|
9753
|
+
const prev1 = Array.isArray(source1) ? source1[1] : this.context.data.series[source1][1];
|
|
9754
|
+
const prev2 = Array.isArray(source2) ? source2[1] : this.context.data.series[source2][1];
|
|
9755
|
+
return prev1 > prev2 && current1 < current2;
|
|
9756
|
+
}
|
|
9757
|
+
pivothigh(source, _leftbars, _rightbars) {
|
|
9758
|
+
if (_rightbars == void 0) {
|
|
9759
|
+
_rightbars = _leftbars;
|
|
9760
|
+
_leftbars = source;
|
|
9761
|
+
source = this.context.data.high;
|
|
9762
|
+
}
|
|
9763
|
+
const leftbars = Array.isArray(_leftbars) ? _leftbars[0] : _leftbars;
|
|
9764
|
+
const rightbars = Array.isArray(_rightbars) ? _rightbars[0] : _rightbars;
|
|
9765
|
+
const result = pivothigh(source.slice(0).reverse(), leftbars, rightbars);
|
|
9766
|
+
const idx = this.context.idx;
|
|
9767
|
+
return this.context.precision(result[idx]);
|
|
9768
|
+
}
|
|
9769
|
+
pivotlow(source, _leftbars, _rightbars) {
|
|
9770
|
+
if (_rightbars == void 0) {
|
|
9771
|
+
_rightbars = _leftbars;
|
|
9772
|
+
_leftbars = source;
|
|
9773
|
+
source = this.context.data.low;
|
|
9774
|
+
}
|
|
9775
|
+
const leftbars = Array.isArray(_leftbars) ? _leftbars[0] : _leftbars;
|
|
9776
|
+
const rightbars = Array.isArray(_rightbars) ? _rightbars[0] : _rightbars;
|
|
9777
|
+
const result = pivotlow(source.slice(0).reverse(), leftbars, rightbars);
|
|
9778
|
+
const idx = this.context.idx;
|
|
9779
|
+
return this.context.precision(result[idx]);
|
|
9780
|
+
}
|
|
9743
9781
|
}
|
|
9744
9782
|
function atr(high, low, close, period) {
|
|
9745
9783
|
const tr = new Array(high.length);
|
|
@@ -10079,6 +10117,56 @@
|
|
|
10079
10117
|
}
|
|
10080
10118
|
return [supertrend, direction];
|
|
10081
10119
|
}
|
|
10120
|
+
function pivothigh(source, leftbars, rightbars) {
|
|
10121
|
+
const result = new Array(source.length).fill(NaN);
|
|
10122
|
+
for (let i = leftbars + rightbars; i < source.length; i++) {
|
|
10123
|
+
const pivot = source[i - rightbars];
|
|
10124
|
+
let isPivot = true;
|
|
10125
|
+
for (let j = 1; j <= leftbars; j++) {
|
|
10126
|
+
if (source[i - rightbars - j] >= pivot) {
|
|
10127
|
+
isPivot = false;
|
|
10128
|
+
break;
|
|
10129
|
+
}
|
|
10130
|
+
}
|
|
10131
|
+
if (isPivot) {
|
|
10132
|
+
for (let j = 1; j <= rightbars; j++) {
|
|
10133
|
+
if (source[i - rightbars + j] >= pivot) {
|
|
10134
|
+
isPivot = false;
|
|
10135
|
+
break;
|
|
10136
|
+
}
|
|
10137
|
+
}
|
|
10138
|
+
}
|
|
10139
|
+
if (isPivot) {
|
|
10140
|
+
result[i] = pivot;
|
|
10141
|
+
}
|
|
10142
|
+
}
|
|
10143
|
+
return result;
|
|
10144
|
+
}
|
|
10145
|
+
function pivotlow(source, leftbars, rightbars) {
|
|
10146
|
+
const result = new Array(source.length).fill(NaN);
|
|
10147
|
+
for (let i = leftbars + rightbars; i < source.length; i++) {
|
|
10148
|
+
const pivot = source[i - rightbars];
|
|
10149
|
+
let isPivot = true;
|
|
10150
|
+
for (let j = 1; j <= leftbars; j++) {
|
|
10151
|
+
if (source[i - rightbars - j] <= pivot) {
|
|
10152
|
+
isPivot = false;
|
|
10153
|
+
break;
|
|
10154
|
+
}
|
|
10155
|
+
}
|
|
10156
|
+
if (isPivot) {
|
|
10157
|
+
for (let j = 1; j <= rightbars; j++) {
|
|
10158
|
+
if (source[i - rightbars + j] <= pivot) {
|
|
10159
|
+
isPivot = false;
|
|
10160
|
+
break;
|
|
10161
|
+
}
|
|
10162
|
+
}
|
|
10163
|
+
}
|
|
10164
|
+
if (isPivot) {
|
|
10165
|
+
result[i] = pivot;
|
|
10166
|
+
}
|
|
10167
|
+
}
|
|
10168
|
+
return result;
|
|
10169
|
+
}
|
|
10082
10170
|
|
|
10083
10171
|
var __defProp$2 = Object.defineProperty;
|
|
10084
10172
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
package/dist/pinets.dev.cjs
CHANGED
|
@@ -9723,6 +9723,44 @@ class TechnicalAnalysis {
|
|
|
9723
9723
|
const idx = this.context.idx;
|
|
9724
9724
|
return [[this.context.precision(supertrend[idx]), direction[idx]]];
|
|
9725
9725
|
}
|
|
9726
|
+
crossover(source1, source2) {
|
|
9727
|
+
const current1 = Array.isArray(source1) ? source1[0] : source1;
|
|
9728
|
+
const current2 = Array.isArray(source2) ? source2[0] : source2;
|
|
9729
|
+
const prev1 = Array.isArray(source1) ? source1[1] : this.context.data.series[source1][1];
|
|
9730
|
+
const prev2 = Array.isArray(source2) ? source2[1] : this.context.data.series[source2][1];
|
|
9731
|
+
return prev1 < prev2 && current1 > current2;
|
|
9732
|
+
}
|
|
9733
|
+
crossunder(source1, source2) {
|
|
9734
|
+
const current1 = Array.isArray(source1) ? source1[0] : source1;
|
|
9735
|
+
const current2 = Array.isArray(source2) ? source2[0] : source2;
|
|
9736
|
+
const prev1 = Array.isArray(source1) ? source1[1] : this.context.data.series[source1][1];
|
|
9737
|
+
const prev2 = Array.isArray(source2) ? source2[1] : this.context.data.series[source2][1];
|
|
9738
|
+
return prev1 > prev2 && current1 < current2;
|
|
9739
|
+
}
|
|
9740
|
+
pivothigh(source, _leftbars, _rightbars) {
|
|
9741
|
+
if (_rightbars == void 0) {
|
|
9742
|
+
_rightbars = _leftbars;
|
|
9743
|
+
_leftbars = source;
|
|
9744
|
+
source = this.context.data.high;
|
|
9745
|
+
}
|
|
9746
|
+
const leftbars = Array.isArray(_leftbars) ? _leftbars[0] : _leftbars;
|
|
9747
|
+
const rightbars = Array.isArray(_rightbars) ? _rightbars[0] : _rightbars;
|
|
9748
|
+
const result = pivothigh(source.slice(0).reverse(), leftbars, rightbars);
|
|
9749
|
+
const idx = this.context.idx;
|
|
9750
|
+
return this.context.precision(result[idx]);
|
|
9751
|
+
}
|
|
9752
|
+
pivotlow(source, _leftbars, _rightbars) {
|
|
9753
|
+
if (_rightbars == void 0) {
|
|
9754
|
+
_rightbars = _leftbars;
|
|
9755
|
+
_leftbars = source;
|
|
9756
|
+
source = this.context.data.low;
|
|
9757
|
+
}
|
|
9758
|
+
const leftbars = Array.isArray(_leftbars) ? _leftbars[0] : _leftbars;
|
|
9759
|
+
const rightbars = Array.isArray(_rightbars) ? _rightbars[0] : _rightbars;
|
|
9760
|
+
const result = pivotlow(source.slice(0).reverse(), leftbars, rightbars);
|
|
9761
|
+
const idx = this.context.idx;
|
|
9762
|
+
return this.context.precision(result[idx]);
|
|
9763
|
+
}
|
|
9726
9764
|
}
|
|
9727
9765
|
function atr(high, low, close, period) {
|
|
9728
9766
|
const tr = new Array(high.length);
|
|
@@ -10062,6 +10100,56 @@ function calculateSupertrend(high, low, close, factor, atrPeriod) {
|
|
|
10062
10100
|
}
|
|
10063
10101
|
return [supertrend, direction];
|
|
10064
10102
|
}
|
|
10103
|
+
function pivothigh(source, leftbars, rightbars) {
|
|
10104
|
+
const result = new Array(source.length).fill(NaN);
|
|
10105
|
+
for (let i = leftbars + rightbars; i < source.length; i++) {
|
|
10106
|
+
const pivot = source[i - rightbars];
|
|
10107
|
+
let isPivot = true;
|
|
10108
|
+
for (let j = 1; j <= leftbars; j++) {
|
|
10109
|
+
if (source[i - rightbars - j] >= pivot) {
|
|
10110
|
+
isPivot = false;
|
|
10111
|
+
break;
|
|
10112
|
+
}
|
|
10113
|
+
}
|
|
10114
|
+
if (isPivot) {
|
|
10115
|
+
for (let j = 1; j <= rightbars; j++) {
|
|
10116
|
+
if (source[i - rightbars + j] >= pivot) {
|
|
10117
|
+
isPivot = false;
|
|
10118
|
+
break;
|
|
10119
|
+
}
|
|
10120
|
+
}
|
|
10121
|
+
}
|
|
10122
|
+
if (isPivot) {
|
|
10123
|
+
result[i] = pivot;
|
|
10124
|
+
}
|
|
10125
|
+
}
|
|
10126
|
+
return result;
|
|
10127
|
+
}
|
|
10128
|
+
function pivotlow(source, leftbars, rightbars) {
|
|
10129
|
+
const result = new Array(source.length).fill(NaN);
|
|
10130
|
+
for (let i = leftbars + rightbars; i < source.length; i++) {
|
|
10131
|
+
const pivot = source[i - rightbars];
|
|
10132
|
+
let isPivot = true;
|
|
10133
|
+
for (let j = 1; j <= leftbars; j++) {
|
|
10134
|
+
if (source[i - rightbars - j] <= pivot) {
|
|
10135
|
+
isPivot = false;
|
|
10136
|
+
break;
|
|
10137
|
+
}
|
|
10138
|
+
}
|
|
10139
|
+
if (isPivot) {
|
|
10140
|
+
for (let j = 1; j <= rightbars; j++) {
|
|
10141
|
+
if (source[i - rightbars + j] <= pivot) {
|
|
10142
|
+
isPivot = false;
|
|
10143
|
+
break;
|
|
10144
|
+
}
|
|
10145
|
+
}
|
|
10146
|
+
}
|
|
10147
|
+
if (isPivot) {
|
|
10148
|
+
result[i] = pivot;
|
|
10149
|
+
}
|
|
10150
|
+
}
|
|
10151
|
+
return result;
|
|
10152
|
+
}
|
|
10065
10153
|
|
|
10066
10154
|
class PineArrayObject {
|
|
10067
10155
|
constructor(array) {
|