English

## Shifting arrays & Filling arrays

Back to topics list To post a new topic, please log in or register
 266 Proximus 2014.03.31 23: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.
 Moderator3206 angevoyageur 2014.04.01 01: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 ?
 1815 SDC 2014.04.01 06: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.
 266 Proximus 2014.04.01 18: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.
 Moderator3206 angevoyageur 2014.04.01 19: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.
 266 Proximus 2014.04.04 20: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.
 13112 WHRoeder 2014.04.04 21: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.
 Moderator3206 angevoyageur 2014.04.04 23:14 #   WHRoeder: See my ResizeBuffer No moving of elements. Your code doesn't compile
 13112 WHRoeder 2014.04.05 00:32 #   angevoyageur: Your code doesn't compile Left as an exersize for the reader

To add comments, please log in or register