'how to remove same elements from and array in pine script
I have an array which contains some zeros in it , i tried this code but label.indexof just delete the first one
for i in arrayname
if i == 0
array.remove(arrayname, array.indexof(i))
if i don't do this my array size gets too large
Solution 1:[1]
Can you check if values are zero before adding them? and if they are zero dont add? That would be best, if not you could try something like this
clearZero(_arr) =>
int i = 0
while i < array.size(_arr) and array.size(_arr) > 0
if array.get(_arr, i) == 0
array.remove(_arr, i)
continue
i += 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bjorgum |
