I want to close the last order ticket but this isn't working?

Back to topics list To post a new topic, please log in or register
avatar
63
Neal_Van 2016.07.16 01:12
 
   int i;                              
   for(i=0; i<OrdersHistoryTotal(); i++)
   {                                    
                                        
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)                         
{
{OrderClose(OrderTicket(),LotSize,Ask,UseSlippage,NULL);}
}
avatar
13001
WHRoeder 2016.07.16 03:30 #
 
  1. Why are you looping by the number of things in History, but looking at orders in trades?
  2. Why are you trying to close all orders, not just the last?
  3. No filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
  4. Define what you mean by last.
  5. Why are you assuming that each ticket has the same size?
  6. Why are you assuming that each ticket is a sell order (close at the Ask)?
  7. Why are you not checking your return codes? What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  8. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
Back to topics list  

To add comments, please log in or register