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.
Hi guys,
I am a bit lost with the deinit function (MT4)..
I want to close all opened orders when something happen that stop the EA, but seems to not do anything. Here is what I wrote but no closing action :
void deinit()
{
total=OrdersTotal();
for (cnt = total - 1; cnt >= 0; cnt--)
ok=OrderSelect(cnt,SELECT_BY_POS);
if(OrderType()==OP_SELL)
ok=OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
if(OrderType()==OP_BUY)
ok=OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
}
Hi guys,
I am a bit lost with the deinit function (MT4)..
I want to close all opened orders when something happen that stop the EA, but seems to not do anything. Here is what I wrote but no closing action :
void deinit()
{
total=OrdersTotal();
for (cnt = total - 1; cnt >= 0; cnt--)
ok=OrderSelect(cnt,SELECT_BY_POS);
if(OrderType()==OP_SELL)
ok=OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
if(OrderType()==OP_BUY)
ok=OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
}
Please help
Please help