about (Multiple Close By)
Forum on trading, automated trading systems and testing trading strategies
Closing Multiple Trades at once
fxsaber, 2017.12.07 09:01
I re-wrote the code slightly
// MQL4&5-code // #include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006 #property strict string CorrectSymbol( string &Symb ) { return(Symb = ((Symb == NULL) || (Symb == "")) ? _Symbol: Symb); } bool PlaceHedge( const string Symb ) { double Lots = 0; for (int i = OrdersTotal() - 1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS) && (OrderType() <= OP_SELL) && (OrderSymbol() == Symb)) Lots += OrderType() ? OrderLots() : -OrderLots(); Lots = NormalizeDouble(Lots, 2); return(((Lots > 0) && (OrderSend(Symb, OP_BUY, Lots, SymbolInfoDouble(Symb, SYMBOL_ASK), 100, 0, 0, "HEDGE") > 0)) || ((Lots < 0) && (OrderSend(Symb, OP_SELL, -Lots, SymbolInfoDouble(Symb, SYMBOL_BID), 100, 0, 0, "HEDGE") > 0)) || !Lots); } bool CloseAll( string Symb = NULL ) { int Type = 0; long Ticket = 0; bool Res = PlaceHedge(CorrectSymbol(Symb)); for (int i = OrdersTotal() - 1; !IsStopped() && Res && (i >= 0); i--) if (OrderSelect(i, SELECT_BY_POS) && (OrderType() <= OP_SELL) && (OrderSymbol() == Symb)) { if (!Ticket) { Ticket = OrderTicket(); Type = OrderType(); } else if ((OrderType() != Type) && (Res = OrderCloseBy(Ticket, OrderTicket()) && PlaceHedge(Symb))) { Ticket = 0; i = OrdersTotal(); } } return(Res); } void OnStart() { CloseAll(); }
I've searched all the MQL5 market looking for an Expert which can do (Multiple Close By) with the ordinary closing actions like (close all, close pending orders, close only buy, close only sell, etc.)
I didn't find a one that can do this important feature (Multiple Close By)
I know that not all brokers support (Multiple Close by).....
my broker does support this feature.
does anyone know an EA with that feature ??
is there an EA which can apply (Multiple Close By) firstly ??? and then apply the normal classic (close)
using (Multiple Close By) can save me a lot of money
I trade on one pair (XAUUSD)
(MultipleCloseBy) works good with one pair