Returns a new array holding the absolute value of every item in a numeric array.
Each negative number is flipped to positive; zero and positive numbers are copied unchanged. The source array is not modified.
The result is always an array of floats, even when the input holds integers.
Syntax
array.abs(id: array<int/float>) -> array<float>
array.abs(id: array<int>) -> array<int>
array.abs() -> array<float>
array.abs() -> array<int>Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | array<int/ | required | The numeric array to take absolute values from. It is left as it is; the result is a new array. |
Returns
array<float>: A new array<float> with the absolute values.array<int>: A new array<int> with the absolute value of each item.array<float>: A new array<float> with the absolute values.array<int>: A new array<int> with the absolute value of each item.
Example
//@version=6
indicator("array.abs: mean move", overlay = false)
var moves = array.new_float()
array.push(moves, close - close[1])
if array.size(moves) > 10
array.shift(moves)
plot(array.avg(array.abs(moves)), "Mean absolute move")See also
Runs on Sidechair