Help: array out of range, though in do...while loop I have tried to check error and exit - page 2

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
iBarShift()
use this function instead of in-built function
mytime: the time you need ti find its index
TF: Time-frame you want to find index in that time frame
As I already said, I don't have a reliable solution for copying timeseries in mql5.
Here and here I pointed out a bug in your code from your first post that resulted in an array out of bounds. I'm afraid I can't help you with anything else.
Hi
Sorry, as you took my reply in a wrong way.
I was not seeking solution from you, but posted for other members to know the limitation of CopySeries().
Regards.
use this function instead of in-built function
mytime: the time you need ti find its index
TF: Time-frame you want to find index in that time frame
Hi @Mahdi Ebrahim
Just saw your post now and thanks a lot for the custom iBarShift().
Will try it and revert.
Regards.
@Vladislav Boyko
Greetings and hope you are doing well.
I have tried all possible ways to use CopySeries() function and following are my observation after failing to succeed in any one of them.
1] If you have timeStart and timeStop parameters and not idxStart and NoOfCount values, this function creates lot of difficulties to convert time to index values. iBarShift() has its own issues for returning incorrect values for many reasons.
2] The problem aggravates, if your start time is on a different timeframe than timeframe required for copying data.
3] MQL should consider another variation of this function with timePosStart and timePosEnd
iBarShift() is not returning incorrect values. I have never seen it and I used it very intensively.
It can return -1, which is not an incorrect value, you need to deal with it.
Yes, variation of CopySeries using time would be nice. But in the meantime you have to deal with what is provided.
I used it very intensively.
Yes, variation of CopySeries using time would be nice. But in the meantime you have to deal with what is provided.
Did I understand correctly that you use iBarShift to find out how many bars you need to copy?
Did I understand correctly that you use iBarShift to find out how many bars you need to copy?
Sometimes.
This is very interesting.
I still continue to work on mql4, where working with timeseries is much easier (thanks to ArrayCopyRates). But for mql5, I was thinking of either copying a fixed number of bars with each Tick/Calculate (the number of bars that will definitely be enough), or storing and updating own snapshot of the necessary charts.
I didn’t think that the option “find out how much you need to copy and copy exactly this amount” is common in serious programs, such as your programs.
On the other hand, this may be due to the fact that your programs have a GUI. That is, the need to copy data once when the user presses a button.
or storing and updating own snapshot of the necessary charts
Roughly speaking, such a thing would emulate the work of MT4 when using ArrayCopyRates. That is, copy the entire chart once, and then with each Tick/Calculate event update only 2 recent bars.
But I think it's quite difficult to develop code that does the job above reliably.
This is very interesting.
I still continue to work on mql4, where working with timeseries is much easier (thanks to ArrayCopyRates). But for mql5, I was thinking of either copying a fixed number of bars with each Tick/Calculate (the number of bars that will definitely be enough), or storing and updating own snapshot of the necessary charts.
I didn’t think that the option “find out how much you need to copy and copy exactly this amount” is common in serious programs, such as your programs.
On the other hand, this may be due to the fact that your programs have a GUI. That is, the need to copy data once when the user presses a button.
I am mainly working on multi-symbols and multi-timeframes indicators/EA. So it's not only getting data for 1 symbol on 1 given timeframe, but up to 35 symbols and 2 or more timeframes. And it needs to work in all situations, when you attach an indicator on a chart, but also when you restart the platform, when it's the week-end, when the computer goes in sleep mode, etc... There is also the need to synchronize data among symbols, and sometimes also among timeframes. It's a complex task. There is never any option which can't be considered when you have a problem to solve.
CopySeries() was introduced as it's the ONLY way to have synchronized data in all circumstances. Unfortunately it currently works with index/count only, so you have to deal with it.
ArrayCopyRates is not an option, it's too slow. Storing/updating a snapshot is not an option either, you will introduce more complexity and you will not solve anything
Why were you thinking it's not an option to “find out how much you need to copy and copy exactly this amount” ?
ArrayCopyRates is not an option, it's too slow.
I was just measuring the time for ArrayCopyRates yesterday. The advisor spends ~15 microseconds with each tick to keep 3 charts up to date (very old and bad computer).
15 microseconds is ArrayCopyRates + RefreshRates + checks. After these 15 microseconds, you have 3 complete, up-to-date charts at your disposal.
But ArrayCopyRates is closely related to the MT4 architecture. Perhaps due to the different architecture, OnTick in MT5 has much lower latency. I find ArrayCopyRates to be very fast for MT4.
MT5 does not have ArrayCopyRates due to the way the terminal works differently (because of this, MT5 is faster and has more features). Perhaps you meant CopyRates and not ArrayCopyRates.