Self-learning the MQL5 language from scratch - page 22

 
Реter Konow:
In fact, the condition above is always true, like 2 = 2. That's why if (the condition operator) doesn't work here and the compiler will generate a warning for this code.

Hello Peter! The compiler hasn't generated any warnings.

Regards, Vladimir.

 
MrBrooklin:

I must have misunderstood something, as there is such a reaction.

I wrote the following condition in the script New6.mq5: "For pending orders Buy Stop and Sell Stop, apply the #define directive instead of input. It will allow us to specify in the script code the necessary types of pending orders, but they will not be displayed in the input parameters of the script when it runs. Let's set variables defining the types of pending orders orderType1 and orderType2. Let's name these variables "BUY_STOP" and "SELL_STOP".

Please advise me what I have done wrong in the implementation of this condition.

Regards, Vladimir.

Everything is in order. There is essentially no condition, just like there is no condition in the expression if (2 == 2). There's some common, everyday logic at work here. :)
 
MrBrooklin:

I must have misunderstood something, as there was such a reaction.

Sincerely, Vladimir.

Respected forum memberKoldun Zloy gave you a detailed answer. There was an error in the macro. Why did you start using macros in the first place? Why do you need them in this task? Macros are a powerful tool that you can easily kill yourself with. But the first thing you do is start using macros.

 
MrBrooklin:

Hello Peter! The compiler hasn't generated any warnings.

Regards, Vladimir.

Supposedly it should have generated a warning prompting you to check the condition. (The yellow triangle in the compilation window).
 
Реter Konow:
Everything is all right. In fact, there is no condition as there is no condition in the if (2 == 2) expression. This is a common, everyday logic. :)

I understand that for programming experts my bloopers look clumsy. Maybe I have made a wrong condition of writing code for myself?

Sincerely, Vladimir.

 
Vasiliy Sokolov:

You, respected forum memberKoldun Zloy gave a detailed answer. The error is in the macro. Why did you start using macros at all? Why do you need them in this task? Macros are a powerful tool that you can easily kill yourself with. But the first thing you do is start using macros.

So, I haven't figured it out yet, and there are some things to work on.

Regards, Vladimir.

 
Реter Konow:
The idea is to give a warning prompting to check the condition. (The yellow triangle in the compile window).

It shouldn't, there's a value on the right and a substitution on the left, so that's correct.

 
MrBrooklin:

I understand that for programming experts my bloopers look clumsy. Maybe I have made a wrong condition of writing code for myself?

Sincerely, Vladimir.

You started your studies in a wrong way. Do you understand everything that is written in the code? All operators, key words?

A follow-up question about the code:

What do these lines mean?

if(!OrderSend(request,result))
      PrintFormat("OrderSend error %d",GetLastError());
 
Реter Konow:
Supposedly it should have generated a warning prompting you to check the condition. (The yellow triangle in the compilation window).

Checked a few more times - the compiler doesn't give out anything.

Regards, Vladimir.

 
MrBrooklin:

I understand that for programming experts my bloopers look clumsy. Maybe I have made a wrong condition of writing code for myself?

Sincerely, Vladimir.

This condition is not needed there at all. What role does it play? Can you explain?
Reason: