parameters object&array[]

 

I noticed in ArrayResize() the formal parameters are defined as such:

int ArrayResize( object &array[], int new_size)

Is object&array[] a way to allow the passing an array of any type as a refered parameter and why cant I do that in my own functions ? (I tried and it seems mql4 wont recognise object)

 
SDC:

I noticed in ArrayResize() the formal parameters are defined as such:

int ArrayResize( object &array[], int new_size)

Is object&array[] a way to allow the passing an array of any type as a refered parameter and why cant I do that in my own functions ? (I tried and it seems mql4 wont recognise object)

You can delete your topic again, at any time https://www.mql5.com/en/forum/139964.

Care to sample us the codes ?

:D

 

That topic is not about my question, it is about fucntions with parameters such as double&array that allow the passing of arrays by reference the usual way ....

My question is about how the ArrayResize() function can accept arrays of any type as parameters and, its formal parameters are described as object&array.

If I had any relevent codes for you to sample you would be welcome to sample them :D

It is just an issue of multiple arrays of different types that I would like to be able to pass to the same function. I did it a different way by making them global so no need to pass them but I would still like to know how object&array works.

 
Interesting question . . . I suspect that some functionality is not exposed via mql4 and is kept within MT4 or coded specially.
 

hmmmm ok well I have another question :D

Scenario:

1) an array[] is global and it is passed to a function as a parameter (for the purpose of identifying it as the array to work on)

2) elements of array[] are accessed in orders closing loop

3) invalid ticket error occurs during that loop (ticket probably already closed because broker SL or TP was met)

4) error passed to errors handling function

5) errors handling function calls function that originaly filled the array, so in effect, refreashes the array.

6) control passed back to orders closing loop in the close orders function ...

So the question is, what state is that array now in as seen in the orders closing loop ? Are changes made to array[] when it was refreashed, there already ? Or does the closing loop still have the old values as they were when array was passed ?

I realise changes made to a global array would usually be available, is that still true when array was passed as a parameter ?

EDIT:

If anyone is interested I wrote a script to test that. When control is passed back to the calling function which then resumes where it left off in the middle of the for loop, the array is now changed and for the remainder of the for loop the array values accessed are the new ones. That is the case whether the array was passed by reference or explicitly in the function parameters.

EDIT2:

Well now I just realized all of that is pointless because if a ticket was closed outside of the EA by SL or TP on the same tick as the order closing loop is executed, refreashing the array of tickets wont make any difference because the terminal would probably not be updated untill the next tick so erroneous order ticket would not be removed from the array ... The answer might have to be skip trying to close any order that returns invalid ticket error and assume it will all be ok on the next tick .

I think writing good error handling code can be really quite difficult to get it right ...