Navigation´╝ÜHome > Content >

Close_All.mq4

Time: 2012-03-24 | Download file:Close_All.mq4

//+------------------------------------------------------------------+
//|                                                    Close_All.mq4 |
//+------------------------------------------------------------------+
 
#property show_inputs
#include 

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   for (int i=0;i<5;i++)
      {
         int total_trades=OrdersTotal();
   
         if (total_trades==0) 
           {
            Alert("Job Done!");
            return(0);
           }
   
         for(int j=0;j=OP_BUYLIMIT) OrderDelete(order_ticket,CLR_NONE);
                  
                  //close sell orders
                  if (order_type==OP_SELL) OrderClose(order_ticket,order_volume,MarketInfo(order_symbol,MODE_ASK),3,CLR_NONE);

                  
                  //close buy orders
                  if (order_type==OP_BUY) OrderClose(order_ticket,order_volume,MarketInfo(order_symbol,MODE_BID),3,CLR_NONE);
               }
            }
      }
   total_trades=OrdersTotal();
   
   if (total_trades>0)
      Alert("Something went wrong! Repeat the script.");
//----
   return(0);
  }
//+------------------------------------------------------------------+

Recommend