Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information
if (mode==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),slippage,Blue); }
if (mode==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),slippage,Red); }
// }
}
}
The problem is that, If I have opened a few pairs it's not always true that all trades will be closed too. Further more, it happend that EA continue to open another trade despite the parameter allowtrading == false.
I was debugging this thing and noticed that for some reason this code block was not executed for all pairs. Why, I don't know. Does somebody know answer to that?
This block should close all opened orders and prevent further trading.Maybe I could resolve this issue with writting parameter false to a file or something? The problem in this situation is also with pairs that have no opened orders.
Here's my code that i wrote long time ago, it will close all running positions.
#include <stdlib.mqh>
#include <WinUser32.mqh>
int start()
{
double sA;
int cnt, totalOrders;
totalOrders = OrdersTotal();
if (totalOrders>0)
{
for (cnt=0;cnt<totalOrders;cnt++)
{
OrderSelect(0, SELECT_BY_POS);
if (OrderType() == OP_BUY) sA = MarketInfo(OrderSymbol(),MODE_BID);
else sA = MarketInfo(OrderSymbol(),MODE_ASK);
OrderClose(OrderTicket(),OrderLots(),sA,3,CLR_NONE );
}
}
return(0);
}