ohlcv-indicators 1.8.3 → 1.8.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.
package/index.js
CHANGED
|
@@ -192,10 +192,10 @@ export default class OHLCV_INDICATORS {
|
|
|
192
192
|
return this
|
|
193
193
|
|
|
194
194
|
}
|
|
195
|
-
bollingerBands(size, times)
|
|
195
|
+
bollingerBands(size, times, bollingerBandsStudies)
|
|
196
196
|
{
|
|
197
197
|
|
|
198
|
-
const result = bollingerBands(this, size, times)
|
|
198
|
+
const result = bollingerBands(this, size, times, bollingerBandsStudies)
|
|
199
199
|
Object.assign(this.indicators, result)
|
|
200
200
|
|
|
201
201
|
this.priceBased.push('bollinger_bands_middle', 'bollinger_bands_upper', 'bollinger_bands_lower')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.4",
|
|
4
4
|
"description": "A JavaScript library featuring optimized trading indicators for OHLCV arrays [{open, high, low, close, value}]. This library is optimized for backtesting and trading bot development.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -2,30 +2,36 @@
|
|
|
2
2
|
import {FasterBollingerBands, FasterSMA} from 'trading-signals';
|
|
3
3
|
import { classifySize } from '../utilities/classification.js';
|
|
4
4
|
|
|
5
|
-
export const bollingerBands = (main, size, times) => {
|
|
5
|
+
export const bollingerBands = (main, size, times, bollingerBandsStudies) => {
|
|
6
6
|
|
|
7
7
|
const {verticalOhlcv} = main
|
|
8
8
|
const {close} = verticalOhlcv
|
|
9
9
|
|
|
10
|
-
const col = getBollingerBands(close, size, times)
|
|
10
|
+
const col = getBollingerBands(close, size, times, bollingerBandsStudies)
|
|
11
11
|
return col
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const getBollingerBands = (data, size = 20, times = 2) => {
|
|
14
|
+
export const getBollingerBands = (data, size = 20, times = 2, bollingerBandsStudies = false) => {
|
|
15
15
|
|
|
16
16
|
const dataLength = data.length
|
|
17
17
|
const bollinger_bands_upper = Array(dataLength).fill(null)
|
|
18
18
|
const bollinger_bands_middle = Array(dataLength).fill(null)
|
|
19
19
|
const bollinger_bands_lower = Array(dataLength).fill(null)
|
|
20
|
-
const bollinger_bands_range = Array(dataLength).fill(null)
|
|
21
|
-
const bollinger_bands_height = Array(dataLength).fill(null)
|
|
22
20
|
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
let bollinger_bands_range
|
|
23
|
+
let bollinger_bands_height
|
|
24
|
+
let heightInstance
|
|
26
25
|
let range = null
|
|
27
26
|
let height = null
|
|
28
27
|
|
|
28
|
+
if(bollingerBandsStudies)
|
|
29
|
+
{
|
|
30
|
+
bollinger_bands_range = Array(dataLength).fill(null)
|
|
31
|
+
bollinger_bands_height = Array(dataLength).fill(null)
|
|
32
|
+
heightInstance = new FasterSMA(size)
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
let getRange = (value, upper, lower) => ({
|
|
30
36
|
range: ((value - lower) / (upper - lower)),
|
|
31
37
|
height: upper-lower
|
|
@@ -52,6 +58,8 @@ export const getBollingerBands = (data, size = 20, times = 2) => {
|
|
|
52
58
|
bollinger_bands_middle[x] = obj.middle;
|
|
53
59
|
bollinger_bands_lower[x] = obj.lower;
|
|
54
60
|
|
|
61
|
+
if(bollingerBandsStudies === false) continue
|
|
62
|
+
|
|
55
63
|
if(hasNull)
|
|
56
64
|
{
|
|
57
65
|
bollinger_bands_range[x] = null
|
|
@@ -79,6 +87,13 @@ export const getBollingerBands = (data, size = 20, times = 2) => {
|
|
|
79
87
|
bollinger_bands_height[x] = classifySize(height, heightMean, 1.5)
|
|
80
88
|
}
|
|
81
89
|
|
|
82
|
-
|
|
90
|
+
let output = { bollinger_bands_upper, bollinger_bands_middle, bollinger_bands_lower }
|
|
91
|
+
|
|
92
|
+
if(bollingerBandsStudies)
|
|
93
|
+
{
|
|
94
|
+
output = {...output, bollinger_bands_range, bollinger_bands_height}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return output
|
|
83
98
|
}
|
|
84
99
|
|