Good article. The concept of what to do and what not to do is well explained.
Errors in specific examples in this case do not reduce the value of the article, as its task is to help people optimise their work style. This task is solved brilliantly, everything is written as simple and clear as possible.
The first value of the variable in the loop is wrong.
Instead of one if, there are two.
string comparison (character) must come at the end.
bool expressions are not bracketed.
Magic variable is missing in the input functions.
The position object was not created.
I didn't see the error the first time until it was published because I didn't code it in the meta-editor but just while writing it, but it's not a big problem because, by the way, all the coding examples used should only have specified
Becoming a good programmer (part 1): getting rid of five habits to become a better MQL5 programmer
This is freelancing, customers most often do not understand the code at all, and bad reviews are not for the quality of the code. I wrote it, the programme did not give profit, so here is the review.
Pearls of wisdom for programmers collected from leading practitioners. - GitHub - 97-things/97-things-every-programmer-should-know: Pearls of wisdom for programmers collected from leading practitio...
1. the error in the loop initialisation is that 1 must be subtracted from the quantity when we do the backtracking.
2. If you could not get the position by the index from the library function, you need to exit the loop with an error and then if you need to process or repeat the function again, otherwise there is a risk of getting an unreliable amount, and you still work with finances, and sometimes there are large amounts in the position, and such a small thing can lead to a loss.
3. First you should check bool variables, then ENUM enumerations and only after that check int, double, string, if the check fails, then immediately go to the next element of the loop.
If you make comparison operations via &&, the programme will necessarily check each condition.
4. The name for the function is also important, it looks better PositionsByType, it seems like a trifle, but when you go to use this function you don't need to go to the library and its table of contents, but just start typing the standard name Positions, and you will have several options for calling PositionsTotal, PositionsByType.....
5. You need to respect the width of the code so that you don't use horizontal scrolling, as this greatly reduces readability and speed of development.
"If you do comparison operations via &&, the programme will necessarily check each condition.".
The comparison is made in order up to the first false.
By the way, in such situations you can also take into account the probability of the condition not being fulfilled.
Yes, you have corrected me correctly, the check will be performed up to the first false, the main thing is that small data types should be first.
In case the conditions consist of functions, the smallest one should be the first and up to the largest one from the point of view of consumed resources, but without breaking the programme logic...
I use this technique in all my projects, the speed gain is noticeable for a tester in optimisation mode.
This is freelancing, customers most often do not understand the code at all, and bad reviews are not for the quality of the code. You wrote it, the programme did not give you profit, that's the review.
Do you tell the customer about this in advance, or is money more important?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Good article. The concept of what to do and what not to do is well explained.
Errors in specific examples in this case do not reduce the value of the article, as its task is to help people optimise their work style. This task is solved brilliantly, everything is written as simple and clear as possible.
Thank you, Omega!
Interesting...
Becoming a good programmer (part 1): getting rid of five habits to become a better MQL5 programmer
Interesting....
Interesting...
Becoming a good programmer (part 1): getting rid of five habits to become a better MQL5 programmer
This is freelancing, customers most often do not understand the code at all, and bad reviews are not for the quality of the code. I wrote it, the programme did not give profit, so here is the review.
A must read for everyone (and the author of the article even more so) : 97 Things Every Programmer Should Know
Variant working faster and in my opinion clearer:
1. the error in the loop initialisation is that 1 must be subtracted from the quantity when we do the backtracking.
2. If you could not get the position by the index from the library function, you need to exit the loop with an error and then if you need to process or repeat the function again, otherwise there is a risk of getting an unreliable amount, and you still work with finances, and sometimes there are large amounts in the position, and such a small thing can lead to a loss.
3. First you should check bool variables, then ENUM enumerations and only after that check int, double, string, if the check fails, then immediately go to the next element of the loop.
If you make comparison operations via &&, the programme will necessarily check each condition.
4. The name for the function is also important, it looks better PositionsByType, it seems like a trifle, but when you go to use this function you don't need to go to the library and its table of contents, but just start typing the standard name Positions, and you will have several options for calling PositionsTotal, PositionsByType.....
5. You need to respect the width of the code so that you don't use horizontal scrolling, as this greatly reduces readability and speed of development.
You are wrong about that:
Yes, you have corrected me correctly, the check will be performed up to the first false, the main thing is that small data types should be first.
In case the conditions consist of functions, the smallest one should be the first and up to the largest one from the point of view of consumed resources, but without breaking the programme logic...
I use this technique in all my projects, the speed gain is noticeable for a tester in optimisation mode.
This is freelancing, customers most often do not understand the code at all, and bad reviews are not for the quality of the code. You wrote it, the programme did not give you profit, that's the review.