tradeinformation multidimensional array

 

Hello,

I want to identify which of the open trades has the biggest open loss.

And then I want to close it or a part of it.

I got the part with the biggest open loss, but I do not know how to add the ticketnumber to that information in the array.

so I could select this one trade after

I guess working with multidimensional arrays would do it, but I do not know how.

This is what I got:

for(cnw = 0; cnw < OrdersTotal(); cnw++) 
{
   if (OrderSelect(cnw, SELECT_BY_POS) && OrderMagicNumber()  == MagicNumber &&  OrderSymbol() == Symbol())
   {
       ArrayResize(openLosses, count+1);
       openLosses[count] = OrderProfit();
       count++; 
   }
}
      if (openLosses[0] != 0) {
            ArrayMinimum(openLosses,WHOLE_ARRAY,0);
            Comment("groesster Verlust: "+openLosses[0]);
      }
 
   int cnw;
   double maxLoss=0;
   int maxLossTicket=-1;
   for(cnw=0; cnw<OrdersTotal(); cnw++)
     {
      if(OrderSelect(cnw,SELECT_BY_POS) && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol())
        {
         if(OrderProfit()<maxLoss) // Loss is < 0
           {
            maxLoss=OrderProfit();
            maxLossTicket=OrderTicket();
           }
        }
     }
   if(maxLossTicket!=-1)
     {
      //...
      Comment("groesster Verlust: "+maxLoss);
     }
 
angevoyageur:


ok, that seems to work. maybe I was thinking way to complicated ......


thanks!