As far as specifics how to code it, I cannot help as I am learning MQL as well. But I do have an idea on the how to store it. Use an array with 20 spots. But if you want to only keep the last 20 items and keep it updated, every time a new bar is closed, you need to cycle through it and re-index so you drop the oldest value and move all down 1 before adding the newest value to the last position in the array.
This is only one possible solution, I am sure that there are many others.
Hi JD4 ,
can you put a simple example? i dont understand your solution.
I dont know what i am having wrong in my code.
Thank you very much for your reply
Hi all,
in this code
int limit = Bars-counted_bars;
i must use ibars??
when i put the code in chart, the chart is black, no line.
Any help please?
This is not specific to MQL in any way, although it might work just straight copy. This is to show concept only.
// This is to show concept only new float Array = BarCloseValueArray[20]; // to load it with zero values for (i = 0; i < BarCloseValueArray.length(); i++) { BarCloseValueArray[i] = 0; } // to place latest bar value at last array position for (i = 0; i < BarCloseValueArray.length() - 1; i++) { int j = i + 1; // sets j index to value of i + 1 to get next index for next step in process BarCloseValueArray[i] = BarCloseValueArray[j]; // sets value at index location i to value of number at index i + i, index[0] set to index[1], // index[1] then set to index[2], and so on } BarCloseValueArray[19] = LastBarCloseValue; // loads value of last bar close to last index of array
I hope this is clearly showing you the thought process I had on how I would do it.
This is not specific to MQL in any way, although it might work just straight copy. This is to show concept only.
I hope this is clearly showing you the thought process I had on how I would do it.
Thank you very much JD4. I am going to apply to my code

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all
i am new in with mql4 and i am learning to programming in this language.
I want draw at time [i] the close value of Bar M5 at all hours 20 miinutes. Ie each H1 bar close i want draw xx:20 (range xx:20-xx:24) M5 close bar.
For example:
Close bar H1 at 11:59 then mql4 draw close bar M5 11:20....
The code that i had is:
Any help will be much appreciated
Thank you very much