Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1247
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Good evening everyone!
In my old age I'm trying to master the basics of MQL5. My curiosity is killing me - I wonder if I can't master programming if I'm about 60. Although, I have made friends with simple HTML, I even created my own web-sites in it. Simple, really, but still... If my questions will cause irritation, then tell me immediately, then I will not ask more naive questions and will not irritate people.
So, opened the first code I saw. I commented out the meaning of one line of this code using Google Translator and MQL5 Reference. What do I ask from the community? Look at the comments and if they are not true, please correct my thinking:
It's an open book to some, but to me it looks like the same Chinese characters. Please don't laugh too hard.
Why am I doing this? Thus, I'm just trying to find out for myself how hopeless I am in programming.
Regards, Vladimir.
I recommend to use the ME helper - it describes the purpose of all operators and language functions.
https://www.mql5.com/ru/docs/trading/positionselect
Good evening everyone!
In my old age I'm trying to master the basics of MQL5. My curiosity is killing me - I wonder if I can't master programming if I'm about 60. Although, I have made friends with simple HTML, I even created my own web-sites in it. Simple, really, but still... If my questions will cause irritation, then tell me immediately, then I will not ask more naive questions and will not irritate people.
So, opened the first code I saw. I commented out the meaning of one line of this code using Google Translator and MQL5 Reference. What do I ask from the community? Look at the comments and if they are not true, please correct my thinking:
It's an open book to some, but to me it looks like the same Chinese characters. Please don't laugh too hard.
Why am I doing this? Thus, I'm just trying to find out for myself how hopeless I am in programming.
Regards, Vladimir.
If you have the will, it is better for your brain than solving crosswords. Just try to understand right away that Hadge accounts are written differently than Netting accounts. This line of code
is used for Netting, but may cause errors in Hadge accounts if more than one position is open.
I recommend using the ME helper - the purpose of all operators and language functions are described there.
https://www.mql5.com/ru/docs/trading/positionselect
Hi Alexey!
Thank you for your feedback. I am using the help in MetaEditor. At the moment the main problem is to understand the purpose of operators and functions, as well as why I need a certain operator or function in a certain place of the program code. It is kind of all described in the FAQ, but as I understand this information is not for those who starts to get into details from scratch, but for those who already has some experience in programming in other languages.
Regards, Vladimir.
If you want to, it's better for your brain than doing crossword puzzles. Just try to understand right away that Hadge accounts are not written the same way as Netting accounts. This line of code
This line of code is used for Netting but might cause errors in Hadge accounts if more than one position is opened.
Hello Alexey!
Thank you for the tip on the Hadge and Netting accounts, as well as for the support.
I have understood that if there is no correction in comments to a code line, it's already good. It means I have understood the essence of this code line as closely as possible. I will continue studying the MQL5 programming and occasionally post my comments. Perhaps, at some point of self-study I will be able to develop a simple Expert Advisor's code on my own.
Sincerely, Vladimir.
Hi all!
I keep learning MQL5 and here is a new line of code, which is not clear even after working with it via Help and Google Translate.
The comment is made by me, but its meaning is not totally clear. I have hardly figured out what FileHandle is. Split it into two words File and Handle. Google translated it as a file descriptor. What is a descriptor and what does it do? It is good that the author of the article explained here https://www.mql5.com/ru/articles/496 that Handle is a unique pointer to something (a file, an indicator, etc.) in Russian.
Now it remains to understand the meaning of all code. I am asking for help from the community, I spent so much time with this code until 3 am, and my head is completely clumsy.
Regards, Vladimir.
Hi all!
I keep learning MQL5 and here is a new line of code, which is not clear even after working with it via Help and Google Translate.
The comment is made by me, but its meaning is not totally clear. I have hardly figured out what FileHandle is. Split it into two words File and Handle. Google translated it as a file descriptor. What is a descriptor and what does it do? It is good that the author of the article explained here https://www.mql5.com/ru/articles/496 that Handle is a unique pointer to something (a file, an indicator, etc.) in Russian.
Now it remains to understand the meaning of all code. I am asking for help from the community, I spent so much time with this code until 3 am, and my head is completely clumsy.
Sincerely, Vladimir.
But why should you translate something in google when the documentation has everything written in Russian?
And I would translate your comment as follows: "Moves file pointer from beginning by 0 bytes. In other words, to the beginning of the file."
Identifier
Description
SEEK_SET
Start of file
SEEK_CUR
Current file position of the file pointer
SEEK_END
End of file
And why translate something with google, when it's written in Russian in the documentation?
And I would translate your comment as, "Moves the file pointer from the beginning to 0 bytes. In other words, to the beginning of the file."
Identifier
Description
SEEK_SET
Start of file
SEEK_CUR
Current file position of the file pointer
SEEK_END
End of file
Hello Alexey!
I googled the meaning of the word combination FileHandle. I wanted to understand what it was and where it came from. The Help did not help me, so I had to Google. When I figured it out, it turned out that the author of the code himself had created a variable for storing the file with a unique pointer. In terms of FileSeek and SEEK_SET the help helped me, but the meaning of the string was not clear. Now, with the help of your tip, it became clear what it is for in a file with a unique pointer.
Thank you very much for your help!
Sincerely, Vladimir.
Hello Alexey!
I googled the meaning of the phrase FileHandle. I wanted to understand what it is and where it came from. The Help was not helpful, so I had to go to Google. The help text for FileSeek and SEEK_SET was very helpful, but the meaning of the string was not clear. Now, with the help of your tip it became clear what it is for in the file with unique pointer.
Thank you very much for your help!
Regards, Vladimir.
The pointer is not unique, it's just the start position of a write or read. Sort of like how we write a statement. The header starts on the second half of the page, the rest of the text on the left edge of the page. Or we start a new paragraph a little back from the edge of the line. This is the beginning of the line and this is the pointer. We can move the beginning of a line to any place in existing text and write or read from that place.
The file handle is unique. It can also be called an identifier. In fact, it is a usual variable. You can call it abrakadabra and assign it a file handle.
Good afternoon !
I'm trying to figure out the indicator code. Stuck on one line.
What does the last line mean and how can it be rewritten in a simpler (clearer) way?
It is written much simpler than any other construction. It's called: ternary operator
I've shown the code conventionally, so hopefully you'll get the hang of itGood afternoon !
I am parsing the code of the indicator. I am stuck on one line.
What does the last line mean and how can it be rewritten in a simpler (clearer) way ?
// cancl[i] = (acD==1 && aoD==1) ? 0 : (acD==2 && aoD==2) ? 1 : (acD==1 && aoD==2)? 2 : 3;
if (acD==1 && aoD==1) { cancl[i]=0; }
else if (acD==2 && aoD==2) { cancl[i]=1; }
else if (acD==1 && aoD==2) { cancl[i]=2; }
else { cancl[i]=3; }
but it's not simpler or clearer in my opinion. It's almost in the style of MT :-) To be in style there should be more strings and they should go in a "staircase" style :-)