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
Please advise how to work correctly with an array which elements are Mqlrates structures.
This is exactly what I want to know:
MqlRates AdaptedRates[];
ArraySetAsSeries(AdaptedRates,true);
AdaptedRates[300].open=1;
The debugger gives an error - Invalid array access.
I understand that using this form of recording, we can only read elements of a structure which is an element of an array.
The question is how to write the structure elements correctly. I am not interested in all of them. The important thing is the price of .open .high .low .close.
I apologize in advance for this question probably very trivial (I'm not the programmer), but help I have not found the answer. I will be grateful for any help.
Set the size of the array. ArrayResize
As far as I understand, if I define size, for example
:) You don't set static array, but set dynamic array size with ArrayResize().
Well, like: ArrayResize(AdaptedRates,302); etc.
You are using a dynamic array AdaptedRates[]. As far as I remember, when working with dynamic arrays you should set their size using the ArrayResize() function. And so far the compiler is crashing on index 300 specified in the third line.
This is a quote from the help.
Swan, Yedelkin thanks for such a quick response.
As far as I understand, if I define a size, for example
yes.
MqlRates AdaptedRates[];//thereby leave the array dynamic
ArrayResize(AdaptedRates,302);//and set the right size
:) You don't set a static array, but set a dynamic one using ArrayResize().
Well, like ArrayResize(AdaptedRates,302); etc.
A glitch in the strategy tester.
It suddenly stops and all local and remote agents have finished and so hangs.
Can you tell me how to start it again, it's a shame to start all over again?Thanks for the popular explanation, as far as I understand it is desirable to ArrayResize it to the required limits before any reference to a dynamic array cell , I will try it.
Note. Only for indicator buffers this will not need to be done. The executive subsystem of the terminal handles this by itself.
Note 2:ArrayResize() should preferably be applied only when it is necessary to change the size of a dynamic array, and not before any access to its elements. It may well be that a dynamic array will be given a size once, and then the program will simply access its items.
Note. Only for indicator buffers this will not need to be done. The executive subsystem of the terminal handles this by itself.
Note 2:ArrayResize() should preferably be applied only when it is necessary to change the size of a dynamic array, and not before any access to its elements. It may well be that a dynamic array will be sized once and then the program will simply access its elements.