Count_Buy-Sell_Position

Author: Copyright 2016, Bola ButBut.
Orders Execution
Checks for the total of open orders
0 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

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