easy way to detect the end of a data hole with the 'new' mql5 functions .. how? - page 2

 
Carl Schreiber:

Well CopyRates() and the other Copy..()-functions 'find' the left end bar of the data hole like iBarShift() - so this is not the problem!

But how do I get with the Copy..()-function easily on the 'other side' of the data hole - this I'd like to know!

But when you say:

how would you do it?

The problem is I don't know what you are trying to do exactly, so difficult to help.

EDIT: I would say, show your code if you need coding help. How do you know there is a hole, in the first place ?

 
Alain Verleyen:

The problem is I don't know what you are trying to do exactly, so difficult to help.

??

I 'landed' in the past at the last valid bar with iBarShift() and/or CopyTime(), CopyRates(), ..

Now I want to get the next valid bar which is the first bar after the data hole.

My situation is as follows (s.a.)

  1. I want to start at: t0 = TimeCurrent() - 5040000; // ~60 days => ~2017.06.14 02:46:10
  2. I landed by iBarShift() or CopyTimes() at t0 = D'2017.03.22 18:06'
  3. The first bar after the hole is ~D'2017.07.07 18:06' which I don't know normally but I want to jump to 'immediately'
  4. Beside that I landed not at the 'closest' bar (Jul. is closer to Jun. than Mar.!!) but the last bar before the hole - which is ok for me!!

But

  1. Neither MQL4 nor MQL4 set an error that the requested bar could not be found, which would be quite helpful!
  2. MQL4 provides iTime() and Time[] (for indis, eas and scripts) to jump easily on the other side of the data hole.
  3. MQL5 seem to request a (quite stupid) try and error or brute force method (increase the time by the the seconds of one bar or try .. until..)!

Any intelligent solution with MQL5-functions to get on the other side of the hole?

I am so angry as I did not expect this behaviour of the MQL5-function and I ended up in an endless loop of an indicator so that I had to kill the terminal and I lost some important charts :(

 

But there is another problem!

I consider that MQL5 with its functions might be caught in an endless loop if there is a data hole in the quotes of the history!
And this might influence not only it's own program but all the other programs running on the terminal as all of a sudden the terminal does not respond any more and has to be killed and restarted after it has been detected: VPS...?

That means that I have to check that myself after every request of theses functions as

  1. Copy..() can't deal with that in a robust manner and
  2. they don't give an hint like setting _Last Error that a problem occurred!

And I guess data holea are not very likely but can appear and a good system should be able to handle that in a proper and robust way!

 
Carl Schreiber:

??

I 'landed' in the past at the last valid bar with iBarShift() and/or CopyTime(), CopyRates(), ..

Now I want to get the next valid bar which is the first bar after the data hole.

  1. Neither MQL4 nor MQL4 set an error that the requested bar could not be found, which would be quite helpful!
  2. MQL4 provides iTime() and Time[] (for indis, eas and scripts) to jump easily on the other side of the data hole.
  3. MQL5 seem to request a (quite stupid) try and error or brute force method (increase the time by the the seconds of one bar or try .. until..)!

Any intelligent solution with MQL5-functions to get on the other side of the hole?

I am so angry as I did not expect this behaviour of the MQL5-function and I ended up in an endless loop of an indicator so that I had to kill the terminal and I lost some important charts :(

I am really not interested by the eternal and senseless discussion between mql4 and mql5 supporters. You have something to solve, use the language, as it is, to solve it. Your problem is you are trying to apply one language logic to an other language.

I already said you how to do, let me repeat more clearly ;

  1. "start_time of CopyTime() = tA[2] = D'2017.03.22 18:06'". You have a date.
  2. Use any way at your disposal to get the index of this date (you know the bar with this date is existing), with mql5, for example iBarshift() I provided you or any simpler way as Bars() (see documentation).
int b1=iBarShift(sym,PERIOD_M1,tA[2],true);
  1. "I 'd like to get the time of the next 5 m1-bars".  Once you have this index from point 2, use CopyTime() with index to get what you want :
int copied=CopyTime(sym,PERIOD_M1,b1-5,5,dates_I_want);
 

For me it's fine have make some stuff yourself ( thinking in MT4 missing features) but I miss a way to can map symbol rates and haven't use copy to buffer. And CopyXXX family needs method for add data to buffer and not use zero index approach. Really CopyXXX method for read one value it's very slow ( 10X slower). It's an unnecessary overhead. If MT5 is a new platform why uses old mt4 behavior in many APIs?

 
Juan Fernandez:

For me it's fine have make some stuff yourself ( thinking in MT4 missing features) but I miss a way to can map symbol rates and haven't use copy to buffer. And CopyXXX family needs method for add data to buffer and not use zero index approach. Really CopyXXX method for read one value it's very slow ( 10X slower). It's an unnecessary overhead. If MT5 is a new platform why uses old mt4 behavior in many APIs?


MT5 provides devs with a deeper access to terminal data. You as a developer can make a class or function to store reused data in memory for later use instead of re-copying buffers. This is all up to you how you want to handle memory management in your code. If you don't like the Core libs features then use a third party lib or make your own. That's the beauty of MQL5 - you have access to a greater variety of functionality due to the less restrictive API. 

 
nicholishen:

MT5 provides devs with a deeper access to terminal data. You as a developer can make a class or function to store reused data in memory for later use instead of re-copying buffers. This is all up to you how you want to handle memory management in your code. If you don't like the Core libs features then use a third party lib or make your own. That's the beauty of MQL5 - you have access to a greater variety of functionality due to the less restrictive API. 


It's not the way. Terminal have all data updated automatically then it's easier if they let map symbol buffers directly. If you want modify data it's when you use CopyXXX. And you don't forget indicators are reloaded everytime you change chart symbol or TF making this kind of tasks not optimal. Really exists that buffer mapping in oncalculate event but you don't have it with other symbols different to chart. 

PS: Problem is not make your own implementation. Problem is can't access some parts forcing to use ugly implementations less efficient

 

The difference is big if MT5 supports symbol history mapping. First run simulate that. All runs are with compiler optimizations