What the Lowest and Highest functions return - page 6

 
I was also thinking, apparently in this situation it's not about pumping up, but about the new bar starting to be built without waiting for the history to be pumped up. And that's kind of right. But on the other hand, imagine a trading Expert Advisor. A connection failure occurs and then the connection is restored. The expert can open a position based on the wrong indicator values until the history is completely swapped. So, the issue is beyond the scope of this topic and concerns the security of autotrading in general. The problem is not simple, of course. Maybe, the solution would be a predefined variable "length of the last continuous period of history"? Indicators (experts) could read it and handle the situation somehow.
 
This is where storing the Bars value (not just Time[0]) can help. That is:

start() {..... if (PrevBars!=Bars-1) { init(); PrevBars=Bars-1; }
 
Those who do serious trading EAs are probably aware of this problem. And some kind of treatment for this situation is included in the EA.
 
Storing of Bars values (not only Time[0]) can help in this case .....

Here is a fragment of that log file which shows that when a new bar starts, the Bars increase by 1 and not by the number of bars to be updated. So it does not help
2006.10.31 23:58:25 CZZ2 EURUSD,M1: shift=0, Bars=38230, Time[shift]=2006.10.31 22:51, High[shift]=1.2763, Low[shift]=1.2763 2006.10.31 23:58:25 CZZ2 EURUSD,M1: shift=1, Bars=38230, Time[shift]=2006.10.31 22:45, High[shift]=1.2762, Low[shift]=1.2762 2006.10.31 23:58:23 CZZ2 EURUSD,M1: shift=0, Bars=38229, Time[shift]=2006.10.31 22:45, High[shift]=1.2762, Low[shift]=1.2762



Those who do serious trading EAs are probably aware of this problem. And some kind of treatment for this situation is included in the EA.

Well, we can try to handle the situation somehow, but it seems we cannot do without some tricky tricks. Especially taking into account the rigid position of MQ on charts without holes.
On the other hand, the terminal knows whether it needs to pump up the history or not. If MQL had access to this knowledge, the problem would be solved much more naturally.


 
Then we compare Time[0] and Time[1]. I myself have only once struggled with such a situation, so I cannot give you a practical code from the start.
 
Then we compare Time[0] and Time[1]. I myself have only once struggled with such a situation, so I cannot give you any practical code. <br / translate="no">.

This will not do anything unless you first enable the code of the "chart without holes" type because existence of holes is a normal situation in MT. Although on large timeframes it will catch almost all failures.
 
In fact, this is a kind of "demonization" :)
The code should be written with maximum protection, because data pumping can be caused not only by the terminal, but also by the ISP, data centre, broker, computer hang-up and so on.
 
By the way, just in case. 28. Search for price extremes - http://www.alpari-idc.ru/ru/experts/articles/29.html
 
I'm afraid that code with maximum protection will be unsuitable for practical use :). Since trading is risky in general, we could have limited ourselves to a reasonable protection. But we are talking here about a rather frequently occurring situation. By the way, my conclusion about better security of large timeframes in previous post was wrong. The previous bar may have incorrect High, Low and Сlose values before history swapping, while the current bar has incorrect High, Low and Open values.
 
Yeah, it turns out that large timeframes are even more dangerous than small ones, because I don't see any simple ways to determine the correctness of data for the last two bars yet. You can imagine an indicator hanging on the minutes and filling the global variable GoodHistoryDepht. Other indicators check this value against their required calculation depth and make decisions. But because of the position of the MQ on the holes, much of the time (and the longer the timeframe, the larger, up to the complete rejection of the daily bars) will be simply unsuitable for trading. Especially given that communication failures prefer to live in real accounts.
Reason: