Download MetaTrader 5

Clean up array, remove all data from array

To add comments, please log in or register
Make profit on MQL5 services. It's easy!
Franco
374
Franco 2010.05.12 23:16 

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!

Viffer
614
Viffer 2010.05.12 23:21  

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

Franco
374
Franco 2010.05.12 23:25  
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!

Phillip
800
Phillip 2010.05.12 23:39  

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

Just set the initialization value to zero.

Franco
374
Franco 2010.05.12 23:42  
1005phillip:

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

Just set the initialization value to zero.


Thanks!
Viffer
614
Viffer 2010.05.13 00:19  

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

V

Phillip
800
Phillip 2010.05.13 01:18  

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

gordon
2326
gordon 2010.05.13 06:04  
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.
Franco
374
Franco 2010.05.13 11:18  

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.

Nikolay Panev
1072
Nikolay Panev 2010.05.13 11:26  
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.

Franco
374
Franco 2010.05.13 12:04  
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
12
To add comments, please log in or register