CloseOrDeleteAll

CloseOrDeleteAll
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself
0 Views
0 Downloads
0 Favorites
CloseOrDeleteAll
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                              CloseOrDeleteAll.mq4|
//|                                                Paul Hampton-Smith| 
//+------------------------------------------------------------------+

// Cleans up all orders regardless of Symbol() or Magic

void init()
{
	// immediate execution
   while(OrdersTotal()>0)
   {
      OrderSelect(0, SELECT_BY_POS, MODE_TRADES);
      switch (OrderType())
      {
      case OP_BUY: OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(),MODE_BID), 5, Purple); break;
      case OP_SELL: OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(),MODE_ASK), 5, Purple); break;
      case OP_BUYSTOP:
      case OP_SELLSTOP: 
      case OP_BUYLIMIT:
      case OP_SELLLIMIT: OrderDelete(OrderTicket());
      }
   }
}

void start()
{
	// nothing more to do
}

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 ---