[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 131

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
Continuation of the theme
Previous here https://www.mql5.com/ru/forum/111497
I'm trying to fill a one-dimensional array ValueArr[].
I'm not sure if it's correct.
On each tick GetValue() function outputs an int value. How do I fill ValueArr[]?
Is my attempt correct?
The array's size should be increased by one on each tick? Then its size will be limited by available computer memory.
Increase the size of the array ValueArr[] using the function ArrayResize() and append the new data into the array. Again - where do you want to add them? At the beginning or at the end?
If at the beginning, you need to move previously written data, otherwise they will be overwritten by the newly written data.
If at the end, then:
Inite set array size = zero, and at start increase it by 1 (size++), then resize the array ( ArrayResize(ValueArr, size);) and write data into cell ValueArr[] indexed by size-1 (ValueArr[size-1]), obtained by GetValue(); (ValueArr[size-1]=GetValue();).
Do you want the size of the array to increase by one on every tick? Then its size will be limited by available computer memory.
At every tick, increase the size of array ValueArr[] using function ArrayResize() and append new data into the array. Again - where do you want to add them? At the beginning or at the end?
If at the beginning, you need to move previously written data, otherwise they will be overwritten by the newly written data.
Inite set array size = zero, and at start increase it by 1 (size++), then resize the array ArrayResize(ValueArr, size); and append data obtained by GetValue() function into ValueArr[] array cell indexed by size-1 (ValueArr[size-1]);
Yes, the data from GetValue() will be written on every tick to ValueArr[] array.
The size of the array is increased with every tick, but it can be defined at once, say, [10000].
Elements of the array are arranged in the order of arrival, i.e., the first written element is the first in the "general queue",
the second element is second in the queue.
If I understood correctly, it looks like this:
I hope I have understood you correctly.
The elements of the array are arranged in order of arrival, i.e. the first one written is first in the "general queue",
why not use a timeseries array?
I'm trying to fill a one-dimensional array ValueArr[].
I'm not sure if it's correct.
On each tick GetValue() function outputs an int value. How do I fill ValueArr[]?
Is my attempt correct?
int ValueArr[size];
you cannot. When declaring an array, you either specify a constant as the size or nothing, and the array is then considered dynamic.
The correct way is this
int ValueArr[]; int init() { ArrayResize(ValueArr,size); }
Please advise! Is there a function in MT4, which would take into account the result of a previous trade to open a new one? If yes, how can I specify it correctly?
Please advise! Is there a function in MT4, which would take into account the result of a previous trade to open a new one? If yes, how can I specify it correctly?
There is no such built-in function, you have to write it yourself, I showed an example here:https://www.mql5.com/ru/forum/131277/page113
This is
you can't. When declaring an array, either a constant is specified as a size, or nothing, and the array is then considered dynamic.
The correct way is this
Then I guess that's it:
Is this right?