Count_Buy-Sell_Position

Author: Copyright 2016, Bola ButBut.
Orders Execution
Checks for the total of open orders
1 Views
0 Downloads
0 Favorites
Count_Buy-Sell_Position
//+------------------------------------------------------------------+
//|                                      Count Buy-Sell Position.mq4 |
//|                                     Copyright 2016, Bola ButBut. |
//|                                   https://M2P_Design@Hotmail.com |
//+------------------------------------------------------------------+
#property library
#property copyright "Copyright 2016, Bola ButBut."
#property link      "https://M2P_Design@Hotmail.com"
#property version   "1.00"
#property strict

input int Magic=280456;
//+------------------------------------------------------------------+
//| Count Buy Orders function                                        |
//+------------------------------------------------------------------+
int CountB()
  {
   int cnt=0;
   for(int i=OrdersTotal()-1; i>=0;i--)
     {
      bool OS=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_BUY)
         cnt++;
     }
   return(cnt);
  }
//+------------------------------------------------------------------+
//| Count Sell Orders function                                       |
//+------------------------------------------------------------------+
int CountS()
  {
   int cnt=0;
   for(int i=OrdersTotal()-1; i>=0;i--)
     {
      bool OS=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && OrderType()==OP_SELL)
         cnt++;
     }
   return(cnt);
  }
//+------------------------------------------------------------------+

Comments