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

 
novichok2018:

This correspondence just shows that in my caseif(!rost) is not the same asif(rost==false). Becausethere is a separate condition forfalse.

You need to start with the basics. These are two absolutely identical entries.

 
Artyom Trishkin:

These are two absolutely identical entries.

Only if the logic of μl4 does not match the logic of Russian (and mathematical logic). Since the expression ("NOT "rost) does not mean that rost==(equal)false, because there is a separate condition stipulating when rost==false. So "not 5" does not mean "2" at all.

 
novichok2018:

Only if the logic of μl4 does not match the logic of Russian (and mathematical logic). Since the expression ("NOT "rost) does not mean that rost==(equal)false, because there is a separate condition stipulating when rost==false. I.e. "not 5" does not mean "2" at all.

If you want rost to be neither 5 nor 2, then set rost as int
 
novichok2018:

Only if the logic of μl4 does not match the logic of Russian (and mathematical logic). Since the expression ("NOT "rost) does not mean that rost==(equal)false, because there is a separate condition stipulating when rost==false. I.e. "not 5" does not mean "2" at all.

Learn the basics ;)

Not only that, but if you set bool rost as 5 or 2, or -5 or -2, it's obviously true, because for boolean variables false is zero, true is everything else.

 
Artyom Trishkin:

Learn the basics ;)

Not only that, but if you set bool rost as 5 or 2, or -5 or -2, then it's definitely true, because for boolean variables false is zero, true is everything else.

So you are trying to explain me the same thingVladislav Andruschenko explained earlier, but I didn't get it:"The second line is irrelevant because you have rost = bool and can take only 2 values and by default it is false" .

Then how do I specify the second condition? With an additional flag? Or no flags at all, just "condition in conditions" ? Surely this is better.

Thank you.

 
novichok2018:

So you are trying to tell me the same thing thatVladislav Andruschenko explained earlier, but I don't get it:"The second line doesn't matter, because you have rost = bool and it can only take 2 values and by default it is false" .

Then how do I specify the second condition? With an additional flag? Or no flags at all, just "condition in conditions" ? This is probably better.

It will be easier to understand if you'll take for granted that programming languages have conventions. For example, n=n+10; Is this correct from the viewpoint of mathematics and logic? And there are a lot of such conventions. You should believe that any number corresponds to a logical value. 0 = false; All other numbers, both positive and negative = true. Here is a script to prove it:

//+------------------------------------------------------------------+
//| Логика языка mql-4                                     PROBA.mq4 |
//+------------------------------------------------------------------+
#property strict
void OnStart()
{
  string s1="Числовое значение n:   ";
  string s2="Логическ значение n: ";
  string s3="ЛогичЧис значение x: ";
  string s4="Числовое значение x:   ";
  bool x;
  int k;
  Alert("-------------------------");
  for(int n=-4; n++<3;)                  // Вот еще: можно ли так цикл записать?  а Вы попробуйте!!!
  {
     s1 +=string(n)+"        ";
     s2 += (n ? "TRUE" : "false")+"   ";
     x=n;
     s3 += (x ? "TRUE" : "false")+"   ";
     k=x;
     s4 += (string)k + "         ";
  }
  Alert(s4);
  Alert(s3);
  Alert(s2);
  Alert(s1);
}

And here is the result:

 
STARIJ:

It will be easier for you to understand if you take it on faith that there are conventions in programming languages. For example, n=n+10; Is this mathematically and logically correct? And there are a lot of such conventions. You should believe that any number corresponds to a logical value. 0 = false; All other numbers, both positive and negative = true. Here's a script to prove it:

And here's the result:

Thank you! Got it about conventions, I'll take it into account. But to understand the suggested script, alas, my knowledge of mcl4 is not enough. Sorry :( .

 
The account has run out of funds and the EA is trying to open an order. The server says"not enough funds for..." and eventually BANNED. Is there any way of not trying if there's no more money?
 
PolarSeaman:
The account has run out of funds and the EA is trying to open an order. The server says "not enough funds for..." and I'm banned. Is there any way we can stop trying if we don't have any more lava?

Yes, there is.

AccountFreeMarginCheck - Информация о счете - Справочник MQL4
AccountFreeMarginCheck - Информация о счете - Справочник MQL4
  • docs.mql4.com
Размер свободных средств, которые останутся после открытия указанного ордера по текущей цене на текущем счете. Если свободных средств не хватает, то будет сгенерирована ошибка 134 (ERR_NOT_ENOUGH_MONEY).
 
Ihor Herasko:

Yes, there is.

Thank you.

Reason: