function OrderTicket()

 
When I test my EA which uses function OrderTicket() I get zero value. The code is:
int Orders[];  
int i=0;
  for(int cnt=0;cnt<OrdersTotal();cnt++){
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGNUM) {
      Orders[i]=OrderTicket();
      Print("Orders[",i,"]: ",Orders[i]);
      i++;
    }
  }
Is this correct? In the manual we read:
"int OrderTicket()
Returns ticket number for the currently selected order.
Note: The order must be previously selected by the OrderSelect() function."

When I use in the testing mode a code:
res=OrderSend(.................);
Print (res);
then I get the number of ticket in the testing order. But this is the last one only.

How can I get the tickets (or the numbers) of active orders in testing mode? Can somebody help me, please?
Thanks,
 
I tried playing with arrays but it seems you need to decide the array size first.
trying modifying the first line to:
int Orders[10];

if it works, try this:
int Orders[];
ArrayResize(Orders,OrdersTotal());
 
lalilo is right. Your Orders array has zero length, because You does not specify it' size.

If You ask GetLastError() after Orders[i]=blah-blah-blah; then You get out of range error.
 
Thank You very, very much!!
I will go on with the development of my EA!
Best Regards!