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])
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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?