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
How to return an array from a function? I've found a workaround so far, but obviously there must be a way to do it "head-on" )).
There is no way to do it head-on... except for a pointer to the array. For example:
CArrayDouble *Function(void);Not head-on, but quite a standard approach, like this, in this section:
In general, the returned array is a parameter-reference...Yeah, thanks. I tried to just immediately
return *x; out of habit, like in C++ ))
instead of
return GetPointer(x)
figured it out ))
New article MQL5 Programming Basics: Arrays is published:
Author: Dmitry Fedoseev
1 Question:
Compiler forbids such construction. Why?
double qwerty(double &q[]);
#import
I'm making a dll and I want to pass an array pointer to it.
But I can't figure out how to do it.
Something's wrong.
I need some analogue of C++
double qwerty(double *q);
double *q;
q = new double [100];
qwerty(q);
How to do it in MQL5...
Thanks for your code it saved me some time to write. I ried to use the MQL5 Array object (double,int etc.) and I just got frustrated. I came to your post and found your code to resize the arrays that was awesome thanks. I modified your code to cater for any data type. Just dont try to use the Contains (Search method) method for objects as it might not work as objects might be references, not sure I haven't tested this. I'm trying to recreate C# inside MQL5 hence the abbreviations are similar :)
God Bless !!!
Then you can declare them like so:
and create them like:
and in the code you use them like a normal class:
ok lets try the english version of MQL.
Thanks for your code post. It saved me time. I tried using the MQL arrays and they were confusing. I then was very depressed that I need to once again need to write basic structures that was supposed to be there BUT then I found your code that saved me some research time on arrays and how to make them grow\increase dynamically. AWESOME thanks.
I hope i can give back to you! the code below works for all data types. It will work on objects too but the Contains (search) method might not work. I only tested it on types (double, int, bool). String might give you problem as well and the code might need to be extended.
Then you can declare it for all types you need like so:
hope this helps anyone