Self-learning the MQL5 language from scratch - page 31

 
Valeriy Yastremskiy:

Exactly logical, not string, as there is an I.)))) in between.

So, I didn't fully understand your question. I missed the point when you asked "... what type of variable is this...". I'm learning. Thank you for the tip!

Regards, Vladimir.

 
Igor Makanu:

this is a completely different condition from the one above, and it's not about the visual difference

It's about the simultaneous execution of the left part of the "AND" and the right part of the "AND".

Hello, Igor! I already understood what the error was. Thanks for the tip!

Regards, Vladimir.

 
MrBrooklin:

Hello, Igor! Already figured out what the mistake was. Thank you for the tip!

Regards, Vladimir.

Yesterday Vasily Sokolov gave recommendations on how to study the language, and the main emphasis was on understanding functions

this is correct and practical - it speeds up development, allows you to divide the task into blocks, allows you to reuse code....

But, imho, you need to learn how to process logical conditions first, it's just a matter of time to find a ready-made user-defined functions or use the standard functions of MQL

But to correctly create logical conditions, as well as to formalize the problem, which is one and the same, is more important.


Logical errors are the worst - everything will work, but when and where it will go wrong... you won't find it ))))


well and on sabotage, if about conditions, write the condition of intersection of 2 MAs, although all thematic forums are filled with this question and answer, but it often happens that such a simple question for a man, may not be so easy to be formalized in the form of logical conditions ;)


UPD: Hello!

 

Once again I would like to thank Valery and Igor for helping me to understand how the bool data type works using such a simple example.

Regards, Vladimir.

 
Igor Makanu:
... Well and on the subject, if about conditions, write the condition of intersection of 2 MAs, although all thematic forums are full of this question and answer, but it often happens that such a simple question for a person may not be so easy to be formalized in the form of logical conditions ;)...

I will definitely give it a try, but a little later. I'm quarantined with the flu and feel that my head doesn't digest new information very well.

Regards, Vladimir.

 
Aliaksandr Hryshyn:
Test question:
"enough time" - what type of variable can this be so that there are no compiler warnings?

Guys, don't bullshit around. Do not take Brooklyn aside. Do not focus on the types.

//+------------------------------------------------------------------+
//|                                                            1.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
string a="достаточно времени";
string b="достаточно терпения";
//---
   if(a!=b)
     {
      Print("я выучу язык MQL 5");
     }
  }

The code works fine. Because at the kernel level, a string comparison function is defined, which returns true if the strings are equal, and false otherwise. When we write a != b, the function comparing the two strings via the literal != is called. By the way, it is up to user to define a comparison function for his own user types, and then they will work in a similar way. So, it is not about types, but about functions again.

But despite being executed correctly, the code is internally inconsistent. In reality the author wanted to express that "if I have enough time" and "enough patience", the result will be "I will learn MQL5". In fact, the result is that one value must not be equal to another in order to learn the language.

 
Vasiliy Sokolov:

Guys, don't bullshit around. Don't take Brooklyn aside. Don't focus on types.

The code works very well. Because at the kernel level, a string comparison function is defined, which returns true if strings are equal and false otherwise. When we write a != b, the function comparing two strings via the literal != is called. By the way, it is up to user to define a comparison function for his own user types, and then they will work in a similar way. So, it is not about types, but about functions again.

But despite being executed correctly, the code is internally inconsistent. In reality the author wanted to express that "if I have enough time" and "enough patience", the result will be "I will learn MQL5". In fact the result is that one value must not necessarily be equal to another to learn the language.

Hello Vasily! Thank you for your support and clarification! Anyway thank you all for sharing your knowledge with me. They are very important to me, especially at this stage!

Sincerely, Vladimir.

 
MrBrooklin:

Hello Vasily! Thank you for your support and for the clarification! Thanks anyway to everyone who has shared their knowledge with me. They are very important to me, especially at this stage!

Feel better now. We will continue afterwards.

 
Vasiliy Sokolov:

Get well. We'll continue afterwards.

Thank you!

Sincerely, Vladimir.

 
Vasiliy Sokolov:
"... However the code, although executed correctly, is internally inconsistent. In reality the author wanted to express that "if I have enough time" and "enough patience" the result will be "I'll learn MQL5". In fact the result is that one value must not be equal to another to learn the language."

First there was this version of the script:

//+------------------------------------------------------------------+
//|                                                            1.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
string a="достаточно времени";
string b="достаточно терпения";
//---
   if(a!=b && b!=a)
     {
      Print("я выучу язык MQL 5");
     }
  }
//+------------------------------------------------------------------+

in which I used a logical "AND". Then I looked that in the condition would be enough for one expression a!=b to print "I'll learn MQL5". In short, I didn't get to the essence of the matter, which was suggested to me by Valery and Igor.

Regards, Vladimir.