You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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