Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1281

 
Nikolai Semko:

After MT5 the feeling of MT4 is just awful.

Nikolay, there is a question about OnCalculate operation in MT5.

When you start the indicator, is OnCalculate called once after OnInit? Or the indicator waits for the tick?

 
MakarFX:

Can you please explain in plain language what the difference between these functions is?

Visually there seems to be no difference. Except for the incomprehensible: || Order_Type ==-1
 
MakarFX:

Could you please explain in plain language what is the difference between these functions?

If we call the first function with the -1 parameter, it will return the number of all orders in the terminal by the current symbol (regardless of their type).

The second function will only return the number of orders whose type is passed to it as a parameter.

 
MakarFX:

Please tell me in plain language what is the difference between these functions?

Nothing, but I would use the second one, but with insertion:||Order_Type==-1

Aleksei Stepanenko:
There seems to be no difference visually. Except for incomprehensible: || Order_Type ==-1.

If we set -1 in the parameter, we will take into account Buy and Sell, which is quite logical for the function to be universal

 
Vitaly Muzichenko:

If we set -1 in the parameter, we take into account Buy and Sell, which is quite logical for the versatility of the function

Ahhhh, I see, thank you.

 
Vitaly Muzichenko:

None, but I would use the second one, but with insertion:||Order_Type==-1

If we set -1 in the parameter, we take into account Buy and Sell, which makes sense for the versatility of the function

Thank you, I got it!

 
Aleksei Stepanenko:

Nikolay, there is a question about OnCalculate in MT5.

When the indicator starts, is OnCalculate called once after OnInit? Or the indicator waits for the tick?

After OnInit is called once, after it waits for tick. Otherwise the main first cycle of indicator generation would not happen on output, when prevCalculated=0.
You can always check the sequence of calls by print.
Print("1");
Print("2");
...
 
Nikolai Semko:
After OnInit is called once, after it waits for tick.
...

Thank you, I have a strange indicator that works on four without any problems. On pairs where there is no tick it did not draw.

Although, prints OnCalculate at start. Perhaps the chart needs to be updated? ChartRedraw? Because it only draws when a tick comes.
Files:
Mike.mq5  17 kb
 
Aleksei Stepanenko:

Thank you, my indicator, which works on four without any problems, behaved strangely. On pairs where there is no tick it did not draw.

I advise to actively use the regular debug. If you do not know how to work with it, you have to learn urgently, there is nothing difficult. It is a quicker way to find errors and answers to questions.
 
Nikolai Semko:
I suggest you actively use the regular debug.

You know, just like you have a terrible feeling about MT4, I'm trying to use MT5 with a feeling of internal rejection, and it's boiling inside , so there's no time for debugging

Reason: