In my EA I have multiple lots. After a price is reached I scale out by taking one
lot off.
The ticket # is i closed and goes into Account History trades and a new ticket#
is created which shows up in trades screen.
If I attempt to modify the stop loss on the remaining lots, I get an unknown ticket
number. The log file shows that it tried to modify using the ticket number of the
lot (original ticket#) that was closed.
When I am doing the following to get the ticket# of the active trades, I get the
old ticket # that was closed.
int total = OrdersTotal();
int ticket;
for (int n = 0; n < total; n++)
{
OrderSelect(n, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()== Symbol())
{
ticket = OrderTicket();
break;
}
// ticket has the ticket#
How can I get the new ticket # of the remaining lots?
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.
The ticket # is i closed and goes into Account History trades and a new ticket# is created which shows up in trades screen.
If I attempt to modify the stop loss on the remaining lots, I get an unknown ticket number. The log file shows that it tried to modify using the ticket number of the lot (original ticket#) that was closed.
When I am doing the following to get the ticket# of the active trades, I get the old ticket # that was closed.
int total = OrdersTotal();
int ticket;
for (int n = 0; n < total; n++)
{
OrderSelect(n, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()== Symbol())
{
ticket = OrderTicket();
break;
}
// ticket has the ticket#
How can I get the new ticket # of the remaining lots?