Flummoxed: unless you can find a problem with this code, MQL5 has a serious bug - page 2

 
Millard Melnyk:

I have a simple indicator that I use a lot in coding and testing, called BarID. Its intent is: for any bar you point to on a chart, to give you both its AsSeries = true and AsSeries = false index values, along with the best I could do to show its date and time, given all that's available are type double data in the Data Window.

All is well at the current end of the chart. The current bar shows as 0 (as series = true) and as rates_total - 1 (as series = false). The (double) bar date and time match the built-in Date and Time of the Data Window.

Cool, it works.

But not at the back end.

I'm testing it on a USDJPY M15 chart.

Hit the Home key to go back to the oldest end of the chart. Everything is initially hunky-dory. The oldest bar shows 0 (as series = false) and  rates_total - 1 (as series = true).

Until you move the mouse around. 

I suggest moving the mouse cursor completely off the chart and then back, then point at the leftmost bar and see how the readouts have changed. Date and Time match the Data Window's Date and Time, the "Total Bars" is unchanged, the same value as rates_total, since every element in its buffer is set to rates_total. But the "Bar# (series)" and "Bar# (regular)" switched all on their own. The leftmost bar on the chart now shows that magic 99,999 for "Bar# (series)", and 79 or 80 for "Bar# (regular)" (I guess that probably depends on how far beyond 99,999 rates_total is.)

Out of the blue.

Just as an FYI, I've abandoned all the i____ functions, (e.g., iTime(), iBars(), iOpen/High/Low/Close, etc.,) because they return zeroes if you go back further than 99,999 bars. Worthless.

Here's an interesting one:

  1. Hit the Home key.
  2. Put your mouse on the leftmost bar.
  3. Carefully take your hand off the mouse and let it rest undisturbed.
  4. Hit the End key, taking you to the most recent end of the chart.
  5. Now, hit the Home key again, with your eyes on the Date Window.

At first, the numbers will be what you'd expect for that leftmost bar.

Then suddenly, spontaneously, its "Bar# (series)" switches to 99,999, the "Bar# (regular)" to 79... and pay special attention to the date.

Before the switcheroo, the date is wrong. As soon as the numbers flip out, the date corrects itself and remains in sync with the Data Window Date and Time.

This shows what I'm encountering in BarID and in another indicator right now (and have in the past, too, which I posted about):

The Data Window shows the oldest bar being 2020.04.20 09:45 (at the moment). But the BarID buffer initially showed it as 2020.04.17 13:45 (which had me chasing my tail in the other indicator I mentioned.) As soon as the index numbers changed, the date buffer corrects itself.

As you can see, the crosshairs are on the leftmost bar, the time legend shows is as 2020.04.20 09:45, agreeing with the data window.

I used the debugger to inspect the buffer, and sure enough, element 0 contains  2020.04.17 13:45.

I have no clue what's going on here.

I'm sure you old-timers who have so much vested in this platform will be positive from the get-go that this is another one of Melnyk's newbie boners. I hope it is. You've got everything you need, I believe, to point my gaff out to me. Otherwise, something's majorly flaky here...

I guess I'm going to put a hard stop limiter in all code from now on, so that I never attempt to deal with series data beyond 99,999 bars. I can see a global variable coming on right now... 

int  giByndHereShallYeNotGo = 99999;


Fix your code..every tick your code executes 8 expensive array operations.. you only need new tick that marks new bar if the indicator is just for bar id
 
Sardion Maranatha #:
Fix your code..every tick your code executes 8 expensive array operations.. you only need new tick that marks new bar if the indicator is just for bar id

All in good time, dude. First I've got to get it to do what I want. What's the point of making it more efficient in doing what I don't want?

 
Millard Melnyk #:

All in good time, dude. First I've got to get it to do what I want. What's the point of making it more efficient in doing what I don't want?

never mind. stay less efficient then.
 
Emanuel Cavalcante Amorim Filho #:

Glad you solved it!! I use i__ functions all the time and never had a problem with them. It might aswell solve this issue.

Hey man, I had occasion to try out iBarShift, iTime, and iClose. They all work now. 

No one has run into these problems, then, because no one was dumb enough to set their chart limit to a mere 100,000 bars and then forget they did it, LMAO!

Thanks for your help, I'm glad you've restored my confidence in the i____ functions, even though it was my own fault for losing it in the first place. Tally-ho! 😁

 
Millard Melnyk #:

Hey man, I had occasion to try out iBarShift, iTime, and iClose. They all work now. 

No one has run into these problems, then, because no one was dumb enough to set their chart limit to a mere 100,000 bars and then forget they did it, LMAO!

Thanks for your help, I'm glad you've restored my confidence in the i____ functions, even though it was my own fault for losing it in the first place. Tally-ho! 😁

Nice! truly glad you solved it! the i_ functions are way more convenient to use than the Copy_ ones =)

 
Sardion Maranatha #:
never mind. stay less efficient then.

LOL, there seems to be a bee in your bonnet.

Reason: