Download MetaTrader 5
To add comments, please log in or register
Find out how to install MetaTrader on Mac OS
Proximus
756
Proximus 2014.03.31 21:54 

Hi i`m curious how the MT4 handles the shifting of the arrays after each tick.And here i`m mostly interested in the Volume[] Array.

My question is that what algoritm shifts back the entire array by 1 element after each new data (in our case tick and/or time for a bar to close relative to timeframe).

I wish to know that algoritm if anyone can describe it to me, the shortest method to achieve this.

Here i will illustrate it in a picture

So basically every new unit of the array is shifted back 1 place to its previous one's place, and if the array has reached its maximum size, then the last ones will be discarded from the array.

In case of the Volume[] array, the close volume of the timeframe is our period when new data comes and shifts the old one's place.

Alain Verleyen
Moderator
28518
Alain Verleyen 2014.03.31 23:08  
Proximus:

Hi i`m curious how the MT4 handles the shifting of the arrays after each tick.And here i`m mostly interested in the Volume[] Array.

My question is that what algoritm shifts back the entire array by 1 element after each new data (in our case tick and/or time for a bar to close relative to timeframe).

I wish to know that algoritm if anyone can describe it to me, the shortest method to achieve this.

Here i will illustrate it in a picture

So basically every new unit of the array is shifted back 1 place to its previous one's place, and if the array has reached its maximum size, then the last ones will be discarded from the array.

In case of the Volume[] array, the close volume of the timeframe is our period when new data comes and shifts the old one's place.

You can't really know how it's managed unless by doing an analysis of the memory usage, which it's not worth the effort.

Why are you asking ?

Ian Venner
2583
Ian Venner 2014.04.01 04:16  
I think it is probably done by re-index the array in reverse, add a new element to the end then reverse the indexing back again.
Proximus
756
Proximus 2014.04.01 16:47  
angevoyageur:

You can't really know how it's managed unless by doing an analysis of the memory usage, which it's not worth the effort.

Why are you asking ?



I`m asking it because i would like to build an indicator which logs volumes, but not by timeframe but by count.It would be like the renko bars, but instead of logging the price, i would log the volume, and for this i need to build my own array of volumes in this manner, since the Volume[] array segmented by timeframe not by count.

And of course i would need it in reverse order, since the Start() is capable of logging in the other direction only.So i guess i need to use the ArrayCopy() aswell.

Alain Verleyen
Moderator
28518
Alain Verleyen 2014.04.01 17:02  
Proximus:

I`m asking it because i would like to build an indicator which logs volumes, but not by timeframe but by count.It would be like the renko bars, but instead of logging the price, i would log the volume, and for this i need to build my own array of volumes in this manner, since the Volume[] array segmented by timeframe not by count.

And of course i would need it in reverse order, since the Start() is capable of logging in the other direction only.So i guess i need to use the ArrayCopy() aswell.

I think best solution is the save time with volume, and build your array from that.
Proximus
756
Proximus 2014.04.04 18:55  
angevoyageur:
I think best solution is the save time with volume, and build your array from that.

Yup, do you think i can reverse the array with ArrayCopy(), because i have already reversed it with for(), but with ArrayCopy it could be done in 1 line.
whroeder1
13593
whroeder1 2014.04.04 19:14  
SDC: I think it is probably done by re-index the array in reverse, add a new element to the end then reverse the indexing back again.
See my ResizeBuffer No moving of elements.
Alain Verleyen
Moderator
28518
Alain Verleyen 2014.04.04 21:14  
WHRoeder:
See my ResizeBuffer No moving of elements.

Your code doesn't compile
whroeder1
13593
whroeder1 2014.04.04 22:32  
angevoyageur: Your code doesn't compile
Left as an exersize for the reader
/
To add comments, please log in or register