Try to use the ArrayCopy() function, please: https://docs.mql4.com/array/ArrayCopy
int lala(int& lala_arr[]) { ArrayResize(lala_arr,2); lala_arr[0]=1; lala_arr[1]=2; return(2); }
int temp[]; int size=lala(temp);
https://docs.mql4.com/basis/variables/formal
alright, thank you very much...I'll try that later :)
see https://docs.mql4.com/basis/variables/formal - parameters passed by reference
oh, I see...with & you just pass the reference...Well, that works. However,
is that really the common way to do it? I've never seen that in another language.
you can use '&' in c++ as well as returning arrays "int* function(){...
return &array;}". Unfortunatelly MQL cant return arrays. but thanks god
has '&' feature. My another disappointment in MQL it doesn't encapsulate variables
properly - in loops for instance.
asmdev, Can you elaborate a bit on the problem of not encpsulating variables properly - in loops? I'm wondering if this is not part of my problem. I'm use to coding any language(Java,c#,etc); I'm new to MQL4 and attempting an indicator using trendlines mainly. I'm using mainly global arrays, resizing and modifying elements, passing them to userfunctions by reference. I find that I'm loosing control or track of variable values in loops especially if i'm iterating all the values along a trendline. I'm not getting the output expected. I try debugging and tracking variables in loops progressively but the results sometimes does not make any sense. Can you share further light on what you meant ealier?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
in a function I want to return an array:
alright, that works. However, how to put the returned var. into a new array?
That doesn't work :/.
Could anybody please tell me how I could get that working?
-
tradeigel