Download MetaTrader 5

How to get rid of anomaly change?

To add comments, please log in or register
SteelAce
188
SteelAce  

I almost succeeded to send and cancel Orders with Mql5. For canceling I used Order ticket as in one sample. Trouble is that in "Trade" tab Order changes itself its status. Before change there exists ticket number (in "Trade" tab that ticket header is called "Order", ticket number is 1010733541) and "Type" is "buy limit", but after that anomalian change ticket number is lost and "Type" is changed to "buy". Because my program recognizes order via ticket number therefore it is unable to cancel that order afterward. Is it somehow possible that Order status stays unchanged?


Before anomaly:

After anomaly:

Thank you!!!

Lorentzos Roussos
10063
Lorentzos Roussos  
SteelAce:

I almost succeeded to send and cancel Orders with Mql5. For canceling I used Order ticket as in one sample. Trouble is that in "Trade" tab Order changes itself its status. Before change there exists ticket number (in "Trade" tab that ticket header is called "Order", ticket number is 1010733541) and "Type" is "buy limit", but after that anomalian change ticket number is lost and "Type" is changed to "buy". Because my program recognizes order via ticket number therefore it is unable to cancel that order afterward. Is it somehow possible that Order status stays unchanged?


Before anomaly:

After anomaly:

Thank you!!!

Use a branding integer which only goes forwards (++).
Put your branding in the orders comment.
If you detect no ticket , search by comments based on the order branding number.
SteelAce
188
SteelAce  
To LoRio: Good idea at first sight, but after that change Order stays invisible to OrdersTotal() command. I didn't try yet but I am afraid that anomalian Order stays inaccessible with mql5 overall. It helps when somehow should be possible to cancel all Orders without ticket. Besides it is truly anomaly because sometimes that change happens and sometimes not. I cannot understand what has influence on that change.
Lorentzos Roussos
10063
Lorentzos Roussos  
SteelAce:
To LoRio: Good idea at first sight, but after that change Order stays invisible to OrdersTotal() command. I didn't try yet but I am afraid that anomalian Order stays inaccessible with mql5 overall. It helps when somehow should be possible to cancel all Orders without ticket. Besides it is truly anomaly because sometimes that change happens and sometimes not. I cannot understand what has influence on that change.
I imagine if you click x it stays there.What is the slippage on that order (if you open it with an EA)?
Stanislav Korotky
18240
Stanislav Korotky  

Pending orders are just "orders" (commands to preform some trading operation in future on the server). When conditions of a pending order are met, the server executes another order - market order - so it has another ticket number.

Please, read this articale carefully - https://www.mql5.com/en/articles/211 - it explains how orders, deals, and positions work in MT5. Basically you should lookup the history for executed order, deal, and position in order to get ticket(s) of market orders which correspond to your pending order - yes, there can be several market orders (and tickets), because your pending order can be filled by parts.

Orders, Positions and Deals in MetaTrader 5
Orders, Positions and Deals in MetaTrader 5
  • 2011.02.01
  • MetaQuotes Software Corp.
  • www.mql5.com
Creating a robust trading robot cannot be done without an understanding of the mechanisms of the MetaTrader 5 trading system. The client terminal receives the information about the positions, orders, and deals from the trading server. To handle this data properly using the MQL5, it's necessary to have a good understanding of the interaction between the MQL5-program and the client terminal.
SteelAce
188
SteelAce  
LoRio:
I imagine if you click x it stays there.What is the slippage on that order (if you open it with an EA)?
I am sorry being so fool again, but I tried to find clicking in that "Trade" tab on that anomaly Order to find something like EA but I cannot see it nowhere. But if you mean that I add x to comment then I am sure that it indeed stays here, but OrdersTotal() counter and other accessing functions cannot see it (that Order alltogether). It is not important is there any comment or not, Mql5 is simply blind. Of course is chance that I understand something wrong. Sorry.
SteelAce
188
SteelAce  
marketeer:

Pending orders are just "orders" (commands to preform some trading operation in future on the server). When conditions of a pending order are met, the server executes another order - market order - so it has another ticket number.

Please, read this articale carefully - https://www.mql5.com/en/articles/211 - it explains how orders, deals, and positions work in MT5. Basically you should lookup the history for executed order, deal, and position in order to get ticket(s) of market orders which correspond to your pending order - yes, there can be several market orders (and tickets), because your pending order can be filled by parts.

Thank you but I am little bit exhausted today already. Tomorrow I read that article what you recommended. It seems right one. Thanks!
SteelAce
188
SteelAce  
Sherlock Holmes has found that (probably) after successful executing Pending Order system automatically starts Position and information about it can be obtained via Position... functions. It was indeed in marketeer's suggested article. However there are nothing about how to avoid that Pending Order behavior or closing Position. Besides Positions also have identifiers.  My dream is now to find command something like KillPosition or CancelPosition or something else like that. Identifier (way to devil itself) I know already.
SteelAce
188
SteelAce  
PositionOpen() and PositionClose() commands in CTrade are solution for this problem. Thanks for attention!
To add comments, please log in or register