Closed orders profit values

 
int start()
{
double OurArray[];
for(int b=0;b<OrdersHistoryTotal();b++)
if(OrderSelect(b,0,0))
if(OrderSymbol()==Symbol())
{
OurArray[b]=OrderTakeProfit();
}

Comment(OurArray[1]);
return(0);
}

Logically it should show a closed order profit value.I spent a lot of time and it not works for me.
Can somebody please help. Thanks.
 

You define the array - double OurArray[];
What size?

 
int start()
  {
 int OurArray[1000];
 
   for(int b=0;b<OrdersHistoryTotal();b++)
     if(OrderSelect(b,0,0))
      if(OrderSymbol()==Symbol())
        OurArray[b]=OrderTakeProfit();
        
       Comment(OurArray[1]);
       
   return(0);
  }
I redid and it still does not work.

 

What is this - if(OrderSelect(b,0,0))???

 
int start()
  {
 int OurArray[1000];
 
   for(int b=0;b<OrdersHistoryTotal();b++)
     if(OrderSelect(b,SELECT_BY_POS,MODE_HISTORY))
      if(OrderSymbol()==Symbol())
        OurArray[b]=OrderTakeProfit();
        
       Comment(OurArray[1]);
       
   return(0);
  }
 

Still not working?

 
Roger:

Still not working?


Have 0 on the output Comment.
 
int start()
  {
int OurArray[1000];

   for(int b=0;b<OrdersHistoryTotal();b++)
     if(OrderSelect(b,SELECT_BY_POS,MODE_HISTORY))
      if(OrderSymbol()==Symbol())
        {OurArray[b]=OrderTakeProfit();
        Print("b - ",b," OrderTakeProfit - ",OrderTakeProfit()," array - ",OurArray[b]);}
       Comment(OurArray[1]);
       
   return(0);
  }
Try this and look at logs.
 
 
This is strange. I decided to help one guy who said that he spent few day without a result.
I worked about 30 min. and see logically all is correct but not works.
 

Try again

int start()
  {
double OurArray[1000];

   for(int b=0;b<OrdersHistoryTotal();b++)
     if(OrderSelect(b,SELECT_BY_POS,MODE_HISTORY))
      if(OrderSymbol()==Symbol())
        {OurArray[b]=OrderTakeProfit();
        Print("b - ",b," OrderTakeProfit - ",OrderTakeProfit(),"openprice - ",OrderOpenPrice()," array - ",OurArray[b]);}
       Comment(OurArray[1]);
       
   return(0);
  }