Hi
Reading the docs, and applying the info to the functions I find it confusing.
Under the heading "Position Properties" https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties
In the second line, It states: "For each financial security (symbol) only one open position is possible."
That's outdated information. Years ago MT5 had only netting account, where only 1 position can be open.
The documentation need to be updated.
So the below code should not print out all the "deals" but only the "position", which does not make any sense, because it actually prints all the "deals" and not the positions according to the docs description.
considering that the "Deal Properties" https://www.mql5.com/en/docs/constants/tradingconstants/dealproperties
the first line states "A deal is the reflection of the fact of a trade operation execution based on an order that contains a trade request."
The reason for this question is that the code below failed to close a profitable "deal" with a market order but rather placed a limit order, Why is that? and your comments on the subject title as well.
Many thanks.
A deal can't be closed, a deal is never "open". You are confusing positions, deals and orders.
This code CAN'T placed a limit order, that's just not possible. It can eventually send a market order, which will result in an opposite direction position on a netting account.
if(_Symbol == PositionGetSymbol(i)){ ulong ticketNo = PositionGetTicket(i); if(PositionSelectByTicket(ticketNo)){
These 3 statements are redundant and should never be used together.
- Use PositionGetSymbol() only on a netting account.
- Use PositionGetTicket() on an hedging account, then PositionGetString(PositionGetString(POSITION_SYMBOL) to check it's the symbol you want.
- If you have a recorded ticket, you can use PositionSelectByTicket(), usable on netting and hedging account.
Please do some researches on the forum, code to close an open position (on netting or hedging) has been posted several times.

- www.mql5.com
I try to summarize it short:
Order is only used to to send request to the market. It will be the order until platform open it.
After Opening Order become Position (one for netting account or many for hedging account)
In hedging account order ticket is equal to position ticket.
After position closing (by market or manually) it becomes deal and can be retrieved from deal history.
Pending orders closed before reaching market conditions are also become deals.
All order values during order time on the market can be retrieved from its position only (using PositionGet... functions)
Am I right?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
Reading the docs, and applying the info to the functions I find it confusing.
Under the heading "Position Properties" https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties
In the second line, It states: "For each financial security (symbol) only one open position is possible."
So the below code should not print out all the "deals" but only the "position", which does not make any sense, because it actually prints all the "deals" and not the positions according to the docs description.
considering that the "Deal Properties" https://www.mql5.com/en/docs/constants/tradingconstants/dealproperties
the first line states "A deal is the reflection of the fact of a trade operation execution based on an order that contains a trade request."
The reason for this question is that the code below failed to close a profitable "deal" with a market order but rather placed a limit order, Why is that? and your comments on the subject title as well.
Many thanks.