Strange behaviour of an indicator at weekends (without ticks) - page 2

 
Petr Nosek #:


The strangest thing is that don't need calling ChartRedraw() now and the arrow is displayed. But the same code didn't work (the arrow didn't displayed but the buffer was filled) a few hours ago.

Same code and now without calling  ChartRedraw() isn't the arrow displayed, but the value in the buffer is correct.


To be safe, I will call both ChartSetSymbolPeriod() and ChartRedraw(). This is the only setting that works for me so far under all conditions.

 
Petr Nosek #:

If I skip calling the ChartSetSymbolPeriod() function on the weekend (when there are no ticks) even though the symbol is synchronized, then the code doesn't execute the main loop at all, so nothing is calculated. This can be simulated by entering "Use ChartSetSymbolPeriod" = false.

Without calling ChartSetSymbolPeriod():



With calling ChartSetSymbolPeriod():


My terminal build is older than yours, but I don't know if it is the problem (I don't believe it).

The strangest thing is that don't need calling ChartRedraw() now and the arrow is displayed. But the same code didn't work (the arrow didn't displayed but the buffer was filled) a few hours ago.

Build 4647 is a beta, you should not rely on it to have a correct behaviour.

Sorry, but your code doesn't make sense to me, I suppose because it's oversimplified.

 
Alain Verleyen #:

Sorry, but your code doesn't make sense to me, I suppose because it's oversimplified.

Yes, my code is oversimplified. In the code that I actually use I need to retrieve the history (e.g. using CopyHigh()), but if the data is not synchronized (e.g. when the platform starts), it ends up with error 4401 (Requested history not found) As I said in my first post, the only reason for this dummy code is to show strange behavior on the weekend (without ticks). By strange behaviour I mean that although the values are "calculated" and the indicator buffer is filled, the indicator (usually) does not draw these values in the chart. The fact that the same code (same data) sometimes draws the values is even stranger. 

For my needs, I found a workaround where I call the ChartRedraw() function. With this workaround, the strange behavior described above does not occur. Still, I was looking for the opinion of others here on the forum. Maybe someone has encountered this and knows another workaround.

In any case, I think it's a bug.

 
Petr Nosek #:

Yes, my code is oversimplified. In the code that I actually use I need to retrieve the history (e.g. using CopyHigh()), but if the data is not synchronized (e.g. when the platform starts), it ends up with error 4401 (Requested history not found) As I said in my first post, the only reason for this dummy code is to show strange behavior on the weekend (without ticks). By strange behaviour I mean that although the values are "calculated" and the indicator buffer is filled, the indicator (usually) does not draw these values in the chart. The fact that the same code (same data) sometimes draws the values is even stranger. 

For my needs, I found a workaround where I call the ChartRedraw() function. With this workaround, the strange behavior described above does not occur. Still, I was looking for the opinion of others here on the forum. Maybe someone has encountered this and knows another workaround.

In any case, I think it's a bug.

I never experimented such behaviour (a need for ChartRedraw, but I don't rely on ChartSetSymbolPeriod() which is like a hammer to kill a fly, I coded my own solution) and I could not reproduce your issue (sorry for my initial posts where I was confused).

Please try with a reliable build and keep us posted.

 
Alain Verleyen #:

Please try with a reliable build and keep us posted.

I am currently updating MT5 to build 4731.

No need to use the ChartRedraw() function yet. Yesterday with the older build it also worked sometimes without ChartRedraw(), so I don't want to rush it. This problem only occurs when there are no ticks, which is usually on the weekend. I don't want to spend too much time with this anymore, so I'll disable the use of ChartRedraw() in the code and try it from time to time on the weekend. If I run into the problem again, where the buffer is filled but not drawn to the chart, I'll get back to you.

I agree with your point about using the ChartSetSymbolPeriod() function. Unfortunately, I don't know of any other solution, because if I don't use this function (on the weekend), the main loop in OnCalculate() will execute and the buffer will fill up, but it won't show up on the chart (and in this case, ChartRedraw() won't help either). When using the ChartSetSymbolPeriod() function in an indicator, one have to be careful not to run it over and over again.

Thanks for your cooperation