tp-sl_removing

Author: Copyright � 2016 (Mike eXplosion)
tp-sl_removing
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategy
0 Views
0 Downloads
0 Favorites
tp-sl_removing
//+------------------------------------------------------------------+
//|                                                   TP-SL Removing |
//|                                Copyright © 2016 (Mike eXplosion) |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2016 (Mike eXplosion)"
#property link      "https://www.mql5.com/en/users/mike_explosion"
#property version   "1.0"

#property strict

#property description "Elimina TakeProfit y StopLoss de todas las posiciones."
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CalculateCurrentOrders()
  {
   int buys=0,sells=0;

   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderType()==OP_BUY)
        {
         buys++;
        }
      if(OrderType()==OP_SELL)
        {
         sells++;
        }
     }

   if(buys>0) return(buys);
   else       return(-sells);

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool ClearSLnTP()
  {
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      bool res=OrderModify(OrderTicket(),OrderOpenPrice(),0,0,0,Blue);

     }
   return false;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart()
  {
   if(CalculateCurrentOrders()!=0)
      ClearSLnTP();
  }
//+------------------------------------------------------------------+

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