Testing Code and found OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES) does not change after selected ticket is closed. Anyone know the reason?
I can change it something else to make it work but it is a bit annoying when something does not behave as documentation suggests it will.Read the Documentation . . . MODE_TRADES is only applicable when SELECT_BY_POS
pool | - | Optional order pool index. Used when the selected parameter is SELECT_BY_POS. It can be any of the following values: |
Ah "The pool parameter is ignored if the order is selected by the ticket number" Does NOT mean only selects from the trading pool (as I automatically interprit that) but selects from both the History pool and trading pool.
and hence the sentance that follows. The way explained above only confuses me more
Pool is ONLY used for selecting by position, irrelevant when selecting by ticket number.
If you select by ticket, the OrderCloseTime will be zero/non-zero depending on if it closed or not. For non-closed orders OrderClosePrice is Bid (Buy) or Ask (Sell)
Your GetTicket means your EA in incompatible with every other including manual trading. Always test magic number, and pair, (and TF)
int GetTicket() { int result=-1 ; int i,active ; active = OrdersTotal() ; for (i=active-1; i>=0; i--) { if ( OrderSelect(i,SELECT_BY_POS,MODE_TRADES) ) { if ( Symbol() == OrderSymbol() ) { result=OrderTicket() ; break ; } } } return(result) ; | int GetTicket() { for (int iPos=OrdersTotal(); iPos>=0; iPos--) if( OrderSelect(iPos, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == magic.number && Symbol() == OrderSymbol() ){ return( OrderTicket() ); } return(-1); } |
WHRoeder the ea is to track a manually entered trade and is only used in the init() part of the ea.
SELECT_BY_POS - therefore use 0,1,2,3 to select ticket MODE_TRADES the current active orders MODE_HISTORY the closed orders list.
Probability is we are dealing with a database queries so the ticket query is set to fetch from all your ticket numbers where by pos creates a list of trades with no close time.
Makes sense to me now.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Testing Code and found OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES) does not change after selected ticket is closed. Anyone know the reason?
I can change it something else to make it work but it is a bit annoying when something does not behave as documentation suggests it will.