Self-learning the MQL5 language from scratch - page 54

 
MrBrooklin:

Thank you very much, Andrey! I understand everything about Magic, because several positions can be opened on one symbol, but I have a counter question. Will the EA look through the open positions for all symbols at once, if it is not explicitly pointed to the current symbol? And this despite the fact that it is set for a certain currency pair, for example, EURUSD? Honestly, I do not quite understand this point.

Regards, Vladimir.

Historically, we have to search through the entire trading environment. It's kind of a fool's protection. The user doesn't know which symbol the Expert Advisor throws on))))

OrderTotal and PositionTotal return the number of all orders / positions in the terminal. You can only find out how many positions there are on the symbol using the filter considering that the order/position symbol is equal to the current window symbol)))

There can only be one position in the netting. The position ticket never changes and is used when accessing the position. Therefore for one position we can memorize its ticket and not go through the positions. For a hedge, it is possible to remember 2 tickets.

For pending orders, we can memorize their tickets in different variables or in an array. But this is more difficult.

 
Valeriy Yastremskiy:

Historically, you have to look all over the trading environment. Sort of like a foolproof protection. User doesn't know which symbol the advisor throws to))))

OrderTotal and PositionTotal return the number of all orders / positions in the terminal. You can only find out how many positions there are on the symbol using the filter considering that the order/position symbol is equal to the current window symbol)))

Do not forget about the majicies and order/position type, which helps to accurately sort and determine the number ofopen positions you are looking for)

 
VVT:

Don't forget the majik and the type of order/position, which helps to accurately sort and determine the number ofopen positions you are looking for)

Of course. The question is why we do a search on all orders. Because we have a function that returns the total amount of orders on all symbols but we don't have a function that returns the number of orders on a specified symbol. It's a pity)

 
Valeriy Yastremskiy:

Of course. The question is why we search through all orders. Because there is a function that returns the total number of orders for all instruments and there is no function that returns the number of orders for a given instrument. It's a pity)

Have you tried adding the sought symbol to the search parameter?

 
I need to learn something, too
 
VVT:

Did you try to add the symbol you are looking for to your search?

pending orders, we can memorize their tickets in different variables or in an array. But this is more complicated.

Yes of course)))))
 

Thank you all very much for the tips and advice! Had to be away for a few hours, so wasn't able to reply to everyone at once.

Regards, Vladimir.

 
Vasiliy Sokolov:

Made some edits!

Vasily, thank you! It's not some corrections, but real business advice with a specific meaning. I tried to write everything in a consistent and detailed way only because it's the result of technical thinking. Now I'm well aware of the need to think like a programmer, not an electronic engineer. I hope everything will get better in the way of thinking soon.

Regards, Vladimir.

 
Valeriy Yastremskiy:

Historically, you have to look all over the trading environment. Sort of like a foolproof protection. User doesn't know which symbol the advisor throws to))))

OrderTotal and PositionTotal return the number of all orders / positions in the terminal. You can only find out how many positions there are on the symbol using the filter considering that the order/position symbol is equal to the current window symbol)))

There can only be one position in the netting. The position ticket never changes and is used when accessing the position. Therefore for one position we can memorize its ticket and not go through the positions. For a hedge, it is possible to remember 2 tickets.

For pending orders, we can memorize their tickets in different variables or in an array. But it is more difficult.

Thank you, Valery, for your detailed reply and especially for the information about the ticket.

Sincerely, Vladimir.

 
Vasiliy Sokolov:

Made some edits

Vasily, there is one more thing I need to clarify. In point 2 of the EA algorithm I wrote: "In the EA, create a block of input parameters with two parameters: set "trailing level" and set "trailing step". What do you mean by set the "tra iling level" parameter? It is such a "positive" level of the current price relative to the opening price of a position at which trailing stop loss would be moved to the level of the opening price, i.e. to Breakeven.

Regards, Vladimir.

Reason: