# 如何计算某种货币所持有的多单和空单各自的总量?

40
2007.05.28 06:02

11551
2007.05.29 15:49
This sample about How to calculate numers of each type orders. See it, I hope this is will help you.

```//+------------------------------------------------------------------+
//|                                                     MyOrders.mq4 |
//|                                        http://www.metaquotes.net/ru/ |
//+------------------------------------------------------------------+
#property show_inputs

extern int ExpertMagicNumber=123456;
//+------------------------------------------------------------------+
//|   Calculate all type orders by my MagicNumber                    |
//+------------------------------------------------------------------+
,int & sellLimitNumber,int & buyStopNumber, int & sellStopNumber, int MagicNumber=0 )
{
int res,orderType;
//----
sellNumber=0;
sellLimitNumber=0;
sellStopNumber=0;
for (int i=OrdersTotal()-1;i>=0;i--)
if (OrderSelect(i,SELECT_BY_POS))
{
if (MagicNumber==0 || (OrderMagicNumber()==MagicNumber && MagicNumber!=0))
{
switch(OrderType())
{
case OP_SELL: sellNumber++;break;
case OP_SELLLIMIT: sellLimitNumber++;break;
case OP_SELLSTOP: sellStopNumber++;break;
}
}
}
//----
return(res);
}
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+```

11551
2007.05.29 15:49
This is a script.
40
2007.05.30 02:13
Thank you! Rosh.

11551
2007.05.30 08:56
You're welcome.
/