Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1519
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
Perhaps it is because I have i >= 0. Yours is greater than zero. And the concatenation I was asking about is not accepted by MetaEditor. Although I took it from MetaQuotes article(https://www.mql5.com/ru/articles/12103)...
Why don't you check posTicket for equality to zero? After all, equality to zero according to the documentation indicates an error?
I don't understand the unnecessary checking of magik yet. The point of the code is to be sure that a position is not opened by this particular Expert Advisor on this instrument. There are several Expert Advisors on an instrument. Each of them has its own window. Experts are distinguished by magik.
I wrote it right away
Forum on trading, automated trading systems and testing trading strategies.
Questions from MQL5 MT5 MetaTrader 5 beginners
Alexey Viktorov, 2024.04.15 08:21
This willbe almost correct.
Everyone has his own programming principle and in my opinion this line of your code looks somehow strange
Why check if(total = 0 ......... because if there are no open positions, the loop will not be executed.
And the check if(.........magic != Magic_m)) does not give anything. After all, if a position has a different magic, it will simply start a new iteration of the loop without additional commands.
But it's all for amateurs. If you like it this way, write it this way...
that's why I don't check a ticket for equality with zero. I want it that way and nothing else...
Regarding the magik check, I was talking about something else. You can check for equality and inequality... So, someone likes to check for inequality and forcibly start a new iteration of the loop. But this approach is simply disgusting to me... I prefer checking for equality. If it is the magician I need, then all commands enclosed in curved brackets after the condition are executed. If the magician is someone else's, then a new iteration of the loop will start without additional stress.
The organisation of the loop can be any. The main thing is that the loop should be complete... This variant works without errors as well as the one in all the documentation examples. You just need to debug the loop organised in the same way as in the documentation examples and watch the loop counter change. Then everything will be clear.
Minus, as far as I remember, and all statistics changes with the account of this withdrawal. I used it a couple of years ago, but I didn't like the way the statistics was calculated, so I stopped using it, maybe now something has changed.
Comrades, I have sorted out the topic, but now I have a new question, when I add an indicator to the chart in this way in the OnInit function, I get error 4114.
Here are the parameters and code of the Expert Advisor.
question why?
how to remove indicators from the chart in an Expert Advisor if I have declared them like this in OnInit
and when updating the Expert Advisor for some reason one of the indicators is added again in the same way, but the old ones are not deleted.
not hide but delete
and when updating the Expert Advisor for some reason one of the indicators is added again in the same way, but the old ones are not deleted
not hide but delete
I think it is better to check its existence on the chart before adding an indicator....
can there be someone in one code and whether in the article, the full code of adding and deleting,
or getting an existing one and adding it if it doesn't exist.
In the manual it's in parts, I don't know how to put it together.