Download MetaTrader 5
To add comments, please log in or register
Do you know that MQL5 is an object-oriented language?
Neal_Van
274
Neal_Van 2016.07.15 23:12 
   int i;                              
   for(i=0; i<OrdersHistoryTotal(); i++)
   {                                    
                                        
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)                         
{
{OrderClose(OrderTicket(),LotSize,Ask,UseSlippage,NULL);}
}
whroeder1
13619
whroeder1 2016.07.16 01: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.
/
To add comments, please log in or register