Close All Trades

Author: Pranav Soan
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself
0 Views
0 Downloads
0 Favorites
Close All Trades
//+------------------------------------------------------------------+
//|                                             Close All Trades.mq4 |
//|                                                      Pranav Soan |
//|                                              pranasoan@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Pranav Soan"
#property link      "pranasoan@gmail.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
int total = OrdersTotal();
  for (int y=OrdersTotal()-1; y>=0; y--)
   {
     if (OrderSelect(y,SELECT_BY_POS,MODE_TRADES))
       {
        int ticket=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5,Aqua);
       }
   }
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   
  }
//+------------------------------------------------------------------+

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