Close_All_Pending

Author: (c) 2007 Investatech Inc., www.investatech.com
Close_All_Pending
Orders Execution
Checks for the total of open orders
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
Close_All_Pending
//+------------------------------------------------------------------+
//|                                               Close_All_Open.mq4 |
//|                  (c) 2007  Investatech Inc., www.investatech.com |
//|                                       http://www.investatech.com |
//+------------------------------------------------------------------+
#property copyright "(c) 2007  Investatech Inc., www.investatech.com"
#property link      "http://www.investatech.com"
#property show_inputs
#include <stdlib.mqh>

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   for (int i=0;i<5;i++)
      {
         int total_trades=OrdersTotal();
   
         if (total_trades==0) 
           {
            Alert("Job Done! Visit http://www.pipboxer.com");
            return(0);
           }
   
         for(int j=0;j<total_trades;j++)
            {
              if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES)) 
               {
                  int order_type=OrderType();
                  double order_openprice=OrderOpenPrice();
                  int order_ticket=OrderTicket();
                  double order_volume=OrderLots();
                  string order_symbol=OrderSymbol();
                  
                  //close pending orders
                  if (order_type>=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);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---