Errors, bugs, questions - page 2047

 
Alexey Navoykov:

I don't understand what you want. I said I was talking about "variable initialisation". And in this context, static and global variables behave identically. I even gave you a link to documentation:variable initialization

Note that static and global variables are everywhere there joined together.

And we don't criticize the initialization sequence because it is not related to the problem at hand. Let me remind you that the problem is that the compiler will NOT generate an error where it should. If a static variable is still uninitialized, you cannot access it.

Well, change the global variable's name, if it bothers you that much. It will not affect the result in any way.

Hello, here we go... Did you read the link yourself?

Apart from mql I also know, not very well, only VBA and only there I met the directive requiring initialization of variables. Note that it's solely at the discretion of the programmer. And you want MQ to force initialization of absolutely all variables? And change the initialisation sequence on every claim by such users? You were given the opportunity to deviate from the rules, understanding WHAT you do, and you ask to exclude such an opportunity???

It seems that you are just looking for something to pick on and besmirch the mql language. Remove static from a variable in a class and you'll be happy.

 

What happens when the system variable that we get from GetTickCount() overflows ?

Is there any standard reaction from the terminal?

Is there a need to monitor this moment programmatically and implement a response?

 
Alexey Viktorov:

Hello, here we go... Did you read this link yourself?

Apart from mql I know, also not very well, only VBA and only there I met the directive of obligatory variable initialization. Note that it is solely at the discretion of the programmer. And you want MQ to force initialization of absolutely all variables?

Well therein lies the reason. Not only do you not know very well (and you've said it yourself how many times), you also know VBA, which has little to do with this language. I know C++ quite well. This is a very clear and strict language, no free will is allowed there, that you are fantasizing about. And MQL was created in the image and likeness of C++. So let's stop it. Familiarize yourself with C++ for a start and then there'll be a sense to argue about something.

p.s. By the way, I'm just now realized that you've originally took the conversation in the wrong direction, because I've already forgotten where it all began, and now I've seen my original code again and realized that your first attackhere was completely off-topic. And how could I not pay attention at once! In my code, the static variable is initialized exactly as a constant, as it is described in the documentation. So the problem is that it hasn't initialized shit. And you started telling me that it's because it must be initialized with a constant. And here we go...

 

Why can't I initialise the array with variables?

void (double a, double b,double c )

{

double inp[3]={a,b,c};   // компилятор ругается 'а' - constant expression required      

}

 
Alexey Kochetkov:

Why can't I initialise the array with variables?

Because in MQL you can only initialise with constants.
 
Alexey Navoykov:

Well, therein lies the reason. Not only do you not know very well (and you've said it yourself how many times), but you also know VBA, which has little to do with the language in question. I know C++ quite well. This is a very clear and strict language, no free will is allowed there, that you are fantasizing about. And MQL was created in the image and likeness of C++. So let's stop it. Familiarize yourself with C++ for a start and then there'll be a sense to argue about something.

p.s. By the way, I'm just now realized that you've originally took the conversation in the wrong direction, because I've already forgotten where it all started, and now I've seen my original code again and realized that your first attackhere was completely off-topic. And how could I not pay attention at once! In my code, the static variable is initialized exactly as a constant, as it is described in the documentation. So the problem is that it hasn't initialized shit. And you started telling me that it's because it must be initialized with a constant. And there it goes...

I'm calling you one last time to study the initialization sequence. It seems to me that the ability to think logically is more important than knowledge. You may know all programming languages by heart, but you need to understand the initialization sequence.

A static variable CANNOT be initialized before the global one. And that says it all.

 
ChartNavigate bug
const bool Init = ChartSetInteger(0, CHART_AUTOSCROLL, false) && EventSetTimer(1);  

void OnTimer()
{  
  Print("----------")  ;
  Print(ChartGetInteger(0, CHART_FIRST_VISIBLE_BAR));  

  ChartNavigate(0, CHART_BEGIN, 100);
  
  Print(ChartGetInteger(0, CHART_FIRST_VISIBLE_BAR));
}

Result on ICMarkets-Demo EURCHF M1 (max bars = 5000):

2017.10.18 21:16:00.800 ----------
2017.10.18 21:16:00.800 4899
2017.10.18 21:16:00.801 199930
2017.10.18 21:16:01.821 ----------
2017.10.18 21:16:01.821 199930
2017.10.18 21:16:01.821 4899
2017.10.18 21:16:02.836 ----------
2017.10.18 21:16:02.836 4899
2017.10.18 21:16:02.836 199930
2017.10.18 21:16:03.845 ----------
2017.10.18 21:16:03.845 199930
2017.10.18 21:16:03.855 4899
2017.10.18 21:16:04.864 ----------
2017.10.18 21:16:04.864 4899
2017.10.18 21:16:04.864 199930
2017.10.18 21:16:05.876 ----------
2017.10.18 21:16:05.876 4999
2017.10.18 21:16:05.886 199930

I don't understand anything at all. It should be the same numbers. But in the end the chart jumps all the time.

Does it work for anyone?

 
Alexey Viktorov:

I urge you one last time to familiarise yourself with the initialisation sequence. It seems to me that the ability to think logically is more important than knowledge. You may know all programming languages by heart, but you need to understand the initialization sequence.

A static variable CANNOT be initialized before a global one. And that says it all.

I'm sorry, but I won't pay any more attention to your senseless provocations and in such a tone. I'm already sorry for wasting time on pointless argument with a dilettante. Firstly, you were presenting about constants that didn't concern my situation at all, and with the same aggressive arrogance as now. Now you are making unsubstantiated statements, not even knowing the subject and not understanding how a programming language is organized. Keep your "logical thoughts", conjectures and fantasies to yourself. I'm not interested in them.

 
Kirill Belousov:

What happens when the system variable that we get from GetTickCount() overflows ?

Is there any standard reaction from the terminal?

Is there a need to track this moment programmatically and implement a reaction?

There is no need to implement any reaction.

If you receive the returned value from GetTickCount into a variable of uint type, you can safely get the difference

uint prev_count=GetTickCount();
...
...
uint diff=GetTickCount()-prev_count;

Even if there is an overflow you will get the correct difference. These are peculiarities of operations with unsigned integers. But that's only good if the previous value was obtained exactly the same way (GetTickCount) and if the previous value was obtained not earlier than 49 days ago.

If you check for more or less, you need more operations than simple subtraction

 
fxsaber:
The ChartNavigate bug

Result on ICMarkets-Demo EURCHF M1 (max bars = 5000):

I don't understand anything at all. It should be the same numbers. But in the end the chart jumps all the time.

Is it reproducing?

Why is it a bug?

Navigating a chart doesn't happen right away. It's an asynchronous command. The result of its execution is not guaranteed.

It is as if you pressed the PageUp button and the chart stands still. And suddenly it jerked.

Reason: