Sum Long & Sum Short

 

If somebody know how to sumarize all opened long and short positions separately no mater pairs?

Thank You ind advance,

Mtudersk

 
mtudersk:

If somebody know how to sumarize all opened long and short positions separately no mater pairs?

Thank You ind advance,

Mtudersk

It's extremely simple, just do a simple loop:

 int ntrades=OrdersTotal();
 if (ntrades!=0)
   {
    for (int i=ntrades-1;i>=0;i--)
       {
        if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==True)
          {
           if (OrderType()==OP_BUY)
             {
              //do stuff with Long orders
             }
           if (OrderType()==OP_SELL)
             {
              //do stuff with Short orders
             }
          }
        }
    }