MT5 OrderSelect() doesn't work - Order not found - Error Code: 4754

To add comments, please log in or register
LiMEntal
10
LiMEntal  

Dear Coders,

I'm working on an MT5 Expert Advisor. I would like to use the OrderSelect() function, but it doesn't work for me. Every time I get "Order not fouund" error message.

Here is my code:

int ot = (int)OrderTicket();
if ( OrderSelect(ot) ){
   Print("OrderSelect done.");    // pr() function is for Print
}
else{
   error_code = GetLastError();
   Print("OrderSelect Error on Ticket #",is(ot),". ",ErrorDescription(error_code),". EC: ",IntegerToString(error_code));
}

Toolbox\Experts output:

"OrderSelect Error on Ticket #280472054. Order not found. EC: 4754"

The position (Ticket #280472054) existed. It was open. But the EA couldn't select it. What can be the problem? What can I try to do?

Thank you in advance.

Relative

whroeder1
17943
whroeder1  
  1. "MT5 OrderSelect() doesn't work." Do you really believe that no one in 10+ years has ever realized this? Or is it more likely that it is you that doesn't understand?
  2. The order has opened. It doesn't exist. Select the position.
LiMEntal
10
LiMEntal  
whroeder1:
  1. "MT5 OrderSelect() doesn't work." Do you really believe that no one in 10+ years has ever realized this? Or is it more likely that it is you that doesn't understand?
  2. The order has opened. It doesn't exist. Select the position.

I still do not understand. But thank you for you answer.

I think, I opened a simple Buy market order (not pending order). It was a deal. Really,, I still don't know exactly what 'deal' means. I'll be back on Monday, and test it again...

Minions Labs
1160
Minions Labs  
LiMEntal:

I think, I opened a simple Buy market order (not pending order). It was a deal. Really,, I still don't know exactly what 'deal' means. I'll be back on Monday, and test it again...

You must understand all the concepts and inner workings of an EA, otherwise you will get screwed with unwanted behavior in the future...


https://www.mql5.com/en/articles/211

Orders, Positions and Deals in MetaTrader 5
Orders, Positions and Deals in MetaTrader 5
  • www.mql5.com
The ultimate goal of a trader is to extract profits through the means of trading operations on the financial markets. This article describes the terms and processes of the MetaTrader 5 trading platform, the knowledge of which is necessary for a proper understanding of the work of trade functions of the MQL5 language. Orders — are the trade...
To add comments, please log in or register