ohlcv-indicators 1.8.8 → 1.8.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohlcv-indicators",
3
- "version": "1.8.8",
3
+ "version": "1.8.9",
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",
@@ -19,10 +19,10 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true, classi
19
19
  let candle_bottom_size = new Array(len).fill(null) //scaled bottom size(0, 0.5 and 1)
20
20
  let candle_gap_size = new Array(len).fill(null) //scaled gap between the current open and previous close (-1 to 1)
21
21
  let candle_shadow_size = new Array(len).fill(null) //scaled shadow size high - slow
22
- let candle_close_position = new Array(len).fill(null) //scaled shadow size curr.close - prev.close
23
- let candle_high_position = new Array(len).fill(null) //scaled shadow size curr.high - prev.high
24
- let candle_low_position = new Array(len).fill(null) //scaled shadow size curr.low - prev.low
25
- let candle_open_position = new Array(len).fill(null) //scaled shadow size curr.open - prev.open
22
+ let candle_close_direction = new Array(len).fill(null) //scaled shadow size curr.close - prev.close
23
+ let candle_high_direction = new Array(len).fill(null) //scaled shadow size curr.high - prev.high
24
+ let candle_low_direction = new Array(len).fill(null) //scaled shadow size curr.low - prev.low
25
+ let candle_open_direction = new Array(len).fill(null) //scaled shadow size curr.open - prev.open
26
26
 
27
27
  //instances
28
28
  let topInstance
@@ -30,10 +30,10 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true, classi
30
30
  let gapInstance
31
31
  let bodySizeInstance
32
32
  let shadowSizeInstance
33
- let closePositionInstance
34
- let highPositionInstance
35
- let lowPositionInstance
36
- let openPositionInstance
33
+ let closeDirectionInstance
34
+ let highDirectionInstance
35
+ let lowDirectionInstance
36
+ let openDirectionInstance
37
37
 
38
38
  if(classify)
39
39
  {
@@ -42,10 +42,10 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true, classi
42
42
  gapInstance = new FasterSMA(period)
43
43
  bodySizeInstance = new FasterSMA(period)
44
44
  shadowSizeInstance = new FasterSMA(period)
45
- closePositionInstance = new FasterSMA(period)
46
- highPositionInstance = new FasterSMA(period)
47
- lowPositionInstance = new FasterSMA(period)
48
- openPositionInstance = new FasterSMA(period)
45
+ closeDirectionInstance = new FasterSMA(period)
46
+ highDirectionInstance = new FasterSMA(period)
47
+ lowDirectionInstance = new FasterSMA(period)
48
+ openDirectionInstance = new FasterSMA(period)
49
49
  }
50
50
 
51
51
  for(let x = 0; x < len; x++)
@@ -64,10 +64,10 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true, classi
64
64
  let topSizeMean = null
65
65
  let bodySizeMean = null
66
66
  let shadowSizeMean = null
67
- let closePositionMean = null
68
- let highPositionMean = null
69
- let lowPositionMean = null
70
- let openPositionMean = null
67
+ let closeDirectionMean = null
68
+ let highDirectionMean = null
69
+ let lowDirectionMean = null
70
+ let openDirectionMean = null
71
71
 
72
72
  //directions
73
73
  const isUp = close > open
@@ -78,10 +78,10 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true, classi
78
78
  const topSize = high - Math.max(open, close)
79
79
  const bottomSize = Math.min(open, close) - low
80
80
  const gapSize = Math.abs(prev.close - curr.open)
81
- const closePosition = Math.abs(curr.close - prev.close)
82
- const highPosition = Math.abs(curr.high - prev.high)
83
- const lowPosition = Math.abs(curr.low - prev.low)
84
- const openPosition = Math.abs(curr.open - prev.open)
81
+ const closeDirection = Math.abs(curr.close - prev.close)
82
+ const highDirection = Math.abs(curr.high - prev.high)
83
+ const lowDirection = Math.abs(curr.low - prev.low)
84
+ const openDirection = Math.abs(curr.open - prev.open)
85
85
 
86
86
  if(classify)
87
87
  {
@@ -92,10 +92,10 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true, classi
92
92
 
93
93
  gapInstance.update(gapSize)
94
94
  bodySizeInstance.update(candleBodySize)
95
- closePositionInstance.update(closePosition)
96
- highPositionInstance.update(highPosition)
97
- lowPositionInstance.update(lowPosition)
98
- openPositionInstance.update(openPosition)
95
+ closeDirectionInstance.update(closeDirection)
96
+ highDirectionInstance.update(highDirection)
97
+ lowDirectionInstance.update(lowDirection)
98
+ openDirectionInstance.update(openDirection)
99
99
 
100
100
  try
101
101
  {
@@ -104,10 +104,10 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true, classi
104
104
  gapMean = gapInstance.getResult()
105
105
  bodySizeMean = bodySizeInstance.getResult()
106
106
  shadowSizeMean = shadowSizeInstance.getResult()
107
- closePositionMean = closePositionInstance.getResult()
108
- highPositionMean = highPositionInstance.getResult()
109
- lowPositionMean = lowPositionInstance.getResult()
110
- openPositionMean = openPositionInstance.getResult()
107
+ closeDirectionMean = closeDirectionInstance.getResult()
108
+ highDirectionMean = highDirectionInstance.getResult()
109
+ lowDirectionMean = lowDirectionInstance.getResult()
110
+ openDirectionMean = openDirectionInstance.getResult()
111
111
  }
112
112
  catch(err)
113
113
  {
@@ -116,10 +116,10 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true, classi
116
116
  topSizeMean = null
117
117
  bottomSizeMean = null
118
118
  shadowSizeMean = null
119
- closePositionMean = null
120
- highPositionMean = null
121
- lowPositionMean = null
122
- openPositionMean = null
119
+ closeDirectionMean = null
120
+ highDirectionMean = null
121
+ lowDirectionMean = null
122
+ openDirectionMean = null
123
123
  }
124
124
 
125
125
  //negatives and positives
@@ -131,22 +131,22 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true, classi
131
131
  ? classifySize(gapSize, gapMean, 2, changeLevel)
132
132
  : -Math.abs(classifySize(gapSize, gapMean, 2, changeLevel)) || 0;
133
133
 
134
- candle_close_position[x] = (isUp)
135
- ? classifySize(closePosition, closePositionMean, 2, changeLevel)
136
- : -Math.abs(classifySize(closePosition, closePositionMean, 2, changeLevel)) || 0;
134
+ candle_close_direction[x] = (isUp)
135
+ ? classifySize(closeDirection, closeDirectionMean, 2, changeLevel)
136
+ : -Math.abs(classifySize(closeDirection, closeDirectionMean, 2, changeLevel)) || 0;
137
137
 
138
- candle_high_position[x] = (isUp)
139
- ? classifySize(highPosition, highPositionMean, 2, changeLevel)
140
- : -Math.abs(classifySize(highPosition, highPositionMean, 2, changeLevel)) || 0;
138
+ candle_high_direction[x] = (isUp)
139
+ ? classifySize(highDirection, highDirectionMean, 2, changeLevel)
140
+ : -Math.abs(classifySize(highDirection, highDirectionMean, 2, changeLevel)) || 0;
141
141
 
142
142
 
143
- candle_low_position[x] = (isUp)
144
- ? classifySize(lowPosition, lowPositionMean, 2, changeLevel)
145
- : -Math.abs(classifySize(lowPosition, lowPositionMean, 2, changeLevel)) || 0;
143
+ candle_low_direction[x] = (isUp)
144
+ ? classifySize(lowDirection, lowDirectionMean, 2, changeLevel)
145
+ : -Math.abs(classifySize(lowDirection, lowDirectionMean, 2, changeLevel)) || 0;
146
146
 
147
- candle_open_position[x] = (isUp)
148
- ? classifySize(openPosition, openPositionMean, 2, changeLevel)
149
- : -Math.abs(classifySize(openPosition, openPositionMean, 2, changeLevel)) || 0;
147
+ candle_open_direction[x] = (isUp)
148
+ ? classifySize(openDirection, openDirectionMean, 2, changeLevel)
149
+ : -Math.abs(classifySize(openDirection, openDirectionMean, 2, changeLevel)) || 0;
150
150
 
151
151
 
152
152
  //positives only
@@ -158,9 +158,9 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true, classi
158
158
  //negatives and positives
159
159
  candle_body_size[x] = candleBodySize
160
160
  candle_gap_size[x] = gapSize
161
- candle_close_position[x] = closePosition
162
- candle_high_position[x] = highPosition
163
- candle_low_position[x] = lowPosition
161
+ candle_close_direction[x] = closeDirection
162
+ candle_high_direction[x] = highDirection
163
+ candle_low_direction[x] = lowDirection
164
164
 
165
165
  //positives only
166
166
  candle_top_size[x] = topSize
@@ -176,9 +176,9 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true, classi
176
176
  candle_top_size,
177
177
  candle_bottom_size,
178
178
  candle_shadow_size,
179
- candle_close_position,
180
- candle_high_position,
181
- candle_low_position,
182
- candle_open_position
179
+ candle_close_direction,
180
+ candle_high_direction,
181
+ candle_low_direction,
182
+ candle_open_direction
183
183
  }
184
184
  }