There is no fail. It works as designed.
Read the note for the OrderSelect()
It says:
The pool parameter is ignored if the order is selected by the ticket number. The ticket number is a unique order identifier.
To find out from what list the order has been selected, its close time must be analyzed. If the order close time equals to 0, the order is open or pending and taken from the terminal open orders list.
If you supply correct ticket, OrderSelect() will return true, ignoring the pool parameter.
As second quoted line states, you have to check OrderCloseTime().
- docs.mql4.com
I read the note, ok, so I can eliminate MODE__TRADES?
I don't understand why it doesn't change the variable if it is TRUE and the order is closed in the historical...
I will read OrderCloseTime but I don't understand how it can help me...
It works like this because MetaQuotes developers built it this way and we have to live with that. If you want to change something, try writing to the Service Desk.
If you select orders by ticket, then the pool can be omitted.
Read the documentation for the OrderCloseTime()
It has only two lines of text, and one of them answers your question. If you can't understand it, please copy the text you don't understand here, and we'll go through it.
P.S.
Why is it so hard for people here to even try to read existing documentation?
- docs.mql4.com
It's very simple!
if orderclosetime differs zero you are dealing with a closed order and if it is zero the order is still open.
{
//Do something with closed order.
}
else
{
//Order not closed yet.
}
Hello, thank you both...
Yes, yesterday I read OrderCloseTime, I think it's what I need...
Thank's for the example, Today I will try and comment !
Thank You really so much !!
I could finish my "EA" !!!
Great !!
...
Why is it so hard for people here to even try to read existing documentation?
Can you read it for me please ? And provide me a summary...no more than 500 words.
I will be grateful forever.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I'm newbie with mql4 but I have some experience programming in other languages...
This is not my first EA or code... but I don't understand where I fail, so please I need help.
In the array ticketoperacioneslong I memorize the ticket of the orders i placed.
I want to be advised , informed, when a ticket (that is inside the array) is in the history list, it has been closed, for TP or SL, doesn't care...
I suppose that when i select with orderselect it should responde with true or false, i set in MOD_HISTORY and TICKET so if the ticket is in the historical it should return TRUE
I post the cicle I try to programming, please tell me where is the error because like this it tell me that all trades are in the history but they are not, they are still opened or pending...
int ticketl=ticketoperacioneslong[a]; //write in "ticketl" the ticket of the array - from 0 to max.lenght of array
Print("ticket in position array ticket ",a," is ticket ",ticketl); //print the ticket in the position "a" is "ticketl"
if (OrderSelect(ticketl,SELECT_BY_TICKET,MODE_HISTORY)==true) //if the selected ticket is in historical actualize the array true/false in "false"
{
operacioneslong[a]=false; // actualize the other array in position "a" with false because it is in historical
Print ("I set the array true/false in false - array n ",a, " of this ticket that is in historical= ", ticketl); // check to view result that i actualized the array
}
}
The result is that all tickets inside the array result to be in historical !! but they are not !!
Where is the fail?
Thank You !!