Array Syncing to Orders table

 

Anyone have any code snippet that will take an array and keep it synchronized to the orders in the orders table? Basically, I have some custom values that I need to track based on the ticket number. I can add into the array with no problem, my concern is the system closes orders based on stop loss values set, if one or more is closed by stop, I need to ensure that my array is corrected on the trades closed.

So I thought of something like this:

void UpdateTArray()

{

int total = OrdersTotal();

double tempArray[total, 2];

for(int i = 0; i <= total; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderTicket == TArray[i,0])

{

tempArray[i,0] = TArray[i,0];

tempArray[i,1] = TArray[i,1];

tempArray[i,2] = TArray[i,2];

}

}

ArrayReSize(TArray, total);

ArrayCopy(TArray, tempArray);

}

Does this look right to you?