How to remove values from Array

 

My Array index[] has 5 values

0.0

0.0

458.2

30.2

0.0


I want to remove values which are 0.0

How can i do that?

Expecting result :

458.2

30.2

 
You can loop through the array. You can use an write-index within any loop. You can write each value not equal to zero to the current write index of the array. You can use ArrayResize to shrink the array. Combine these functionalities like each software developer.
 
Arpit T: How can i do that?
You write some code. Next time, show us your code and state the nature of your problem?
Not compiled, not tested, just typed.
#define INDEX uint
   template<typename Ti, typename To>
   INDEX      remove_copy(const Ti& inp[], INDEX iBeg, INDEX iEnd,
                                To& out[], INDEX oBeg, const Ti& value){
      for(; iBeg != iEnd; ++iBeg){
         if(!(inp[iBeg] == value) )    out[oBeg++] = inp[iBeg];
      }
      return oBeg;
   }
/////////////
   double index[]={0.0, 30.2, 458.2, 0.0, 0.0, 0.0}
   ArrayResize( index, remove_copy(index, 0, ArraySize(index), index, 0, 0.0) );
Not compiled, not tested, just typed.
 
William Roeder #:
You write some code. Next time, show us your code and state the nature of your problem?
Not compiled, not tested, just typed. Not compiled, not tested, just typed.

Or read the documentation. Granted, it is greatly overrated.

https://www.mql5.com/en/docs/array/arrayremove

 
Enrique Dangeroux #: Or read the documentation. Granted, it is greatly overrated.
  1. ArrayRemove doesn't exist in MT4. Language was unclear from OPs post.
  2. ArrayRemove removes elements. OP wants specific values removed.  Use would be inefficient. O(n²) not O(n)