Rz_Clear_All_SL_n_TP

Author: Copyright 2014, Rony Nofrianto
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
Rz_Clear_All_SL_n_TP
//+------------------------------------------------------------------+
//|                                             RoNz Auto SL n TP.mq4|
//|                                   Copyright 2014, Rony Nofrianto |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Rony Nofrianto"
#property link      ""
#property version   "1.00"
#property strict

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