Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
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);
}