Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1335

 
how can I open an account?
 
Artyom Trishkin:

There shouldn't be any difference. It just looks nicer to me - the code is less loaded with parentheses and indents.

For one check (if) yes, but in code there are two, and if there are many, then logic If Yes, contingency and new loop iteration, Otherwise action A logic If No then action otherwise pass to next condition If No. In this case, the body of the loop will go all the way through.

 
Valeriy Yastremskiy:

For one check (if) yes, but there are two in the code, and if there are many, then the logic If Yes, continue and a new loop iteration, Otherwise action A logic If No then action otherwise pass to the next condition If No. In this case, the loop body will go through to the end.

I don't understand anything, but let it be so.

 
Artyom Trishkin:

They will. I use it because I want to :) This explicitly specifies which class methods are used.

If you have two classes, one as parent and one as an inherited class, and they have two methods with the same name, but they are not virtual for some reason, you have to explicitly specify which method to use.

Suppose parent class is CParent and inherited class is CInheritedand they both have Method() method.

In this case, if we call a method Method() of a CParent class, it will explicitly call a method of the CParent class - this is not required here. We can call the method with or without it.

If wecall aMethod() method in an inherited CInherited class, the methodof that class will also be called, since we first look for a method belonging to the class we called it from.

If wecall CParent::Method() in a CInherited class, it is the method of the parent class that will be called this way, because we have explicitly specified a method that belongs to the parent class by context resolution operator.

But still I would call method Method() in CInherited class withindication this - to be sure that method of this (this == "this") inherited class will be called.

There are other explanations for using this. Maybe someone more experienced in OOP can tell us.

Artem, thank you very much for such a comprehensive answer, which changes the attitude to OOP for the better).

 
Ахад Ахмедрв:
How do I open a live account?

1. Choose a broker.
2. Choose a platform, MT4 or MT5.
3. Open a live account with the broker.

 
Artyom Trishkin:

Well, yes. I'm one of those "some people", especially when I call a standard function from a class, I make sure to specify the global context. Just because I can think of adding a method in that class with the same name as the standard function - so I'll never forget what it does. And that's when you need :: to call a standard function, and this - to call my method with the same name.

Artem, it already disproves the second part of expression "necessary - not necessary". It is necessary, means it is necessary. There is no objection...

 

Hello

How to calculate the distance in pips from the current price to the nearest limitpending order. I'm interested in a ready-made code.


 
Valeriy Yastremskiy:

For one check (if) yes, but there are two in the code, and if there are many, then the logic If Yes, continue and a new loop iteration, Otherwise action A logic If No then action otherwise pass to the next condition If No. In this case the body of the loop will go all the way through.

For me, the preferred option is

int a = 3, b = 7;
for(int i = 0; i < 10; i++)
 {
  if(i == a && b == 7)
   {
    Print(b);
   }
  // если условие if(i == a) НЕ выполнено, следующая итерация………
 }

or this

int a = 3, b = 7;
for(int i = 0; i < 10; i++)
 {
  if(i == a)
   {
    if(b == 7)
     Print(b);
   }
  // если условие if(i == a) НЕ выполнено, следующая итерация………
 }

Another variant

int a = 3, b = 7;
for(int i = 0; i < 10; i++)
 {
  if(i != a)
   continue; // если условие if(i != a) выполнено, следующая итерация………
    if(b == 7)
     Print(b);
 }

The other variant is on the verge of idiocy.

int a = 3, b = 7;
for(int i = 0; i < 10; i++)
 {
  if(i != a)
   continue; // если условие if(i != a) выполнено, следующая итерация………
    if(b != 7)
     continue;
     
  Print(b);
 }

But this is a matter of taste. Whichever one likes.

As far as I understand, this way was used when the if operator checked ALL the conditions from the beginning to the end. It was justified by the fact that if the first condition is not fulfilled, you will not have to check the following conditions. Now all the conditions after the one that was not fulfilled are not checked. And such condition staircases are no longer necessary, only a habit is left.

 
Alexey Viktorov:

Artyom, that already disproves the second part of the "should-don't" expression. If I have to do it, I have to do it. No objection...

With the caveat: if I do.
 
Hello, the strategy tester shows 44% history quality, how do I fix it? Searching the forum didn't give anything, I also looked for some information in the help, there's nothing either.
Reason: