#### Topic: How to calculate number of buy and sells order from history

Hey,

can someone help out how i can calculate the amount of closed buy and sell positions from an ea and put in in a comment to show on chart?

So it must be a calculation for exactly the magicnumber and symbol.

i tried it with this

```
//+------------------------------------------------------------------+
//| Calculate history closed buy positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrdersbuys(int buy)
{
int buys=0;
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number && OrderType()==OP_BUY)
{
buys++;
}
}
return(buys);
}
//+------------------------------------------------------------------+
//| Calculate history closed sell positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrderssells(int sell)
{
int sells=0;
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic_Number)
{
if(OrderType()==OP_BUY) sells++;
}
}
return(sells);
}
```

and this in ontick

```
Comment( "---------------| Buys: ",CalculateCurrentOrdersbuys(0),"\n",
"---------------| Sells: ",CalculateCurrentOrderssells(0));
```