Not to worry, I doubt 2 EA's would want to open at the same time (within a click) very often.
Though I may find other uses for sharing variables so is it possible?
To declare a non dynamic array you can't use a variable! Either use a number arr[32] or a 'defined' number: #define arrSize 32 ... arr[arrSize];
Or you use a dynamic array and then you can use a variable to re-size the array: arr[]; .... ArrayResize(arr, profitsSize);
To declare a non dynamic array you can't use a variable! Either use a number arr[32] or a 'defined' number: #define arrSize 32 ... arr[arrSize];
Or you use a dynamic array and then you can use a variable to re-size the array: arr[]; .... ArrayResize(arr, profitsSize);
Thanks, can I share it across all instances?
Also how can I share variables between Indicators and EA's?
Thanks.
paulgriffiths: can I share it across all instances?
|
|
Can EA's use pointers as in c++?
for example:
double *potentialProfits[32];
Thanks.
Pointers in mql5 are not really pointers (you can't access memory directly).
Also they are available only for object (class instance) not for basic types (int, double...).

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I wish to create an array:
const int profitsSize = 32;
double potentialProfits[profitsSize];
Is it possible to share this array with all instances of my EA?
It's so the EA's can decide which currency pair to open, the most profitable one.
I also need to share an int too(profitIndex) so each EA knows which array index to bind to. And also set the profitIndex to 0 only once.
for example:
int profitIndex;
...
// when first EA loaded
profitIndex = 0;
...
// set bindProfitIndex when each EA is loaded
int bindProfitIndex = profitIndex++;
...
// set potential profit
potentialProfits[bindProfitIndex] = ...;
Can EA's use pointers as in c++?
for example:
double *potentialProfits[32];
Thanks.