talib.ADD
Adds two arrays element by element (Vector Arithmetic Add).
talib.ADD(inReal0, inReal1)Examples
Add the high and low price of each K-line.
javascript
function main() {
var records = exchange.GetRecords()
if (!records) return
// high price plus low price
var highs = records.map(function(r) { return r.High })
var lows = records.map(function(r) { return r.Low })
var ret = talib.ADD(highs, lows)
Log(ret)
}
python
import talib
def main():
records = exchange.GetRecords()
if not records:
return
# high price plus low price
ret = talib.ADD(records.High, records.Low)
Log(ret)Returns
| Type | Description |
numeric array | Results, the same length as the input. |
Arguments
| Name | Type | Required | Description |
inReal0 | numeric array | Yes | First series. |
inReal1 | numeric array | Yes | Second series; it must have the same length as |
See Also
Remarks
TA-Lib equivalent: ADD(Array(inReal0),Array(inReal1)) = Array(outReal).
Calculates inReal0[i] + inReal1[i] element by element.
In JavaScript, both inputs must be numeric arrays (extract a field from the K-line data with map first): if a K-line array is passed, both inputs take the close price of the same K-line data and the result is meaningless; arrays of different lengths raise an error.