Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1517
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
I found this article https://www.mql5.com/ru/articles/286
and in the source code of his advisor is this code
but I can't figure out how to set the necessary parameters, specifically:
No.
It is necessary to select position not by symbol, but by ticket using the PositionGetTicket(i) function and then check magick and symbol.
Do I understand correctly that in this case position_symbol and magic refer to this particular ticket? Does concatenation like ticket.magic or ticket.symbol work? Is the entry correct now?
Is the next entry correct?
A small clarification to your code:
Regards, Vladimir.
Do I understand correctly that in this case position_symbol and magic refer to this particular ticket? Does concatenation like ticket.magic or ticket.symbol work? Is the entry correct now?
it's almost correct.
Everyone has his own programming principle and this line of your code looks strange to me
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, the loop will simply start a new iteration without additional commands.
But it's all for amateurs. If you like it this way, write it this way...
automatically selects this position for further work with it using the PositionGetDouble, PositionGetInteger, PositionGetString functions
Thanks. I was just finding out what exactly this "automatically" could mean.
it's almost right.
Everyone has his own programming principle and this line of your code looks strange to my mind
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, the loop will simply start a new iteration without additional commands.
But it's all for amateurs. If you like it this way, write it this way...
Perhaps it is because I have i >= 0. Yours is greater than zero. And the concatenation I asked 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.
And the concatenation I was asking about is not accepted by MetaEditor. Although I took it from MetaQuote article(https://www.mql5.com/ru/articles/12103)...
By concatenation I found out that, apparently, the class dictates to write m_position instead of position.
By concatenation I found out that apparently the class dictates to write m_position instead of position.
You can name the variable position or m_position as you like, for example, pos, posit, k_pos, k_position, etc., etc.
Regards, Vladimir.
You can name the position or m_position variable anything you want, such as pos, posit, k_pos, k_position, etc. etc. etc.
Regards, Vladimir.
You seem to be confused. Take a look and read the comments on each line carefully:
I hope everything will be clear now. As for the variable, I have already written in this thread that it can be called either position or m_position, etc. etc.
And, please, ask questions in this topic, so it will be easier to get help.
Regards, Vladimir.