Clean up array, remove all data from array

 

Hello,

How can I clean up an array? For example I used an array, the array is now full of data, now I need to remove all data so that I can use it again.

Any idea how I can do this? Replacing all data with 0 in a loop (the array is double) won't work it will interfere with calculations.

I need to make the array as it was before I added any info.

Would appreciate any help

Thanks!

 

Some one more experienced may correct me but as a suggestion, you could resize the array to 0 and resize it back again...

https://docs.mql4.com/array/ArrayResize


HTH

V

 
Viffer:

Some one more experienced may correct me but as a suggestion, you could resize the array to 0 and resize it back again...

https://docs.mql4.com/array/ArrayResize


HTH

V

Good idea V! Thanks!

 

https://docs.mql4.com/array/ArrayInitialize

Just set the initialization value to zero.

 
1005phillip:

https://docs.mql4.com/array/ArrayInitialize

Just set the initialization value to zero.


Thanks!
 

Phil, out of interest, will that work with EMPTY_VALUE ?

V

 

good question V, I have no idea on that, needs to be investigated

 
Viffer:

Phil, out of interest, will that work with EMPTY_VALUE ?

If u use EMPTY_VALUE it would initialize it to the constant's value (the pre-processor simply replaces EMPTY_VALUE with it's value just before compilation):

EMPTY_VALUE0x7FFFFFFFDefault custom indicator empty value.
 

I have still not fixed my problem.

The thing is I use the ArrayMaximum and Minimum in a loop, now if I the array have values from the previous loop, or the values are set to 0, it influences the calculations.

I need to literally remove the values, there must be NOTHING in the array.

 
Saidar:

I have still not fixed my problem.

The thing is I use the ArrayMaximum and Minimum in a loop, now if I the array have values from the previous loop, or the values are set to 0, it influences the calculations.

I need to literally remove the values, there must be NOTHING in the array.

Define NOTHING :)

The array will always contain values. You can fill your array with EMPTY_VALUE and then use ArrayMaximum (), ArrayMinimum() along with a check if max/min value is different from EMPTY_VALUE.

 
robofx.org:

Define NOTHING :)

The array will always contain values. You can fill your array with EMPTY_VALUE and then use ArrayMaximum (), ArrayMinimum() along with a check if max/min value is different from EMPTY_VALUE.


I define nothing as the value the array had, before it got a value. That sounds confusing lol :)

Thanks will try that
Reason: