| / | Forum |
|
|
|
All about Automated Trading Championship: Interviews with the Participants'07 The published interviews of Championship 2007 bear the stamp of the results obtained during the preceding contest. The first Championship evoked a wide response on the internet and in printings. The leading developer of the MetaQuotes Software Corp. tells about changes made to the forthcoming Automated Trading Championship 2007. We put our questions to the developer of a well-known indicating complex ZUP, Eugeni Neumoin (nen) and spoke to an equity trader, Alexander Pozdnishev (AlexSilver). |
|
|
isaacarsenal:
[...] all this things suggest that THERE IS a multiple close! But how i can do this in programatically (in MQL4 language) by a EA? You do use OrderCloseBy() in order to do a multiple-close. However, this is less than simple. You can only pair off two orders at a time (which creates a new order for any difference between them in lot size). To do a multiple close, you have to make repeated calls to OrderCloseBy(). But the speed shouldn't matter enormously; once your buys and sells net out to zero, your cash position should only be affected by movements in the spread, not movements in the price. Therefore, it generally won't matter (significantly) whether the closure is near-instantaneous as it is in the user interface, or somewhat slower in the automated version using repeated calls to OrderCloseBy(). |
|
|
isaacarsenal wrote >>
Is there any way to close all buy/sell trades at once? for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderType()==OP_SELL&&OrderSymbol() == Symbol()) { if(OrderMagicNumber() == MagicN) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Digits),10,CLR_NONE); Sleep(100); } } } |
|
|
EADeveloper:
Example for Close All Sell from an EA [...] isaacarsenal is specifically asking about closing orders by pairing them off against each other, rather than simply closing each individual order separately - i.e. using OrderCloseBy() rather than OrderClose(). On brokers who support it, this usually saves money (spread) and executes faster. |
|
|
I know the OrderCloseBy() function which close pairs of orders. But it cannot close all orders at once. |
|
|
isaacarsenal wrote >>
I know the OrderCloseBy() function which close pairs of orders. But it cannot close all orders at once. |
|
|
isaacarsenal:
I know the OrderCloseBy() function which close pairs of orders. But it cannot close all orders at once. No. As explained in my earlier response. |
|
|
jjc: No. As explained in my earlier response. Can someone please help me with / point me to a pre-written piece of code that I can use to achieve multiple close by ? sat |
|
2032 |
skt1977: There's an example in the book -> http://book.mql4.com/trading/orderclose (in the middle of the page, under "Closing Opposite Orders").Can someone please help me with / point me to a pre-written piece of code that I can use to achieve multiple close by ? |
Is there any way to close all buy/sell trades at once?



There is a "Multiple Close By" feature in N2Trader which can close all buys/sells alternatively until all trades be closed or just one trade (which there are no pair trade for closing it) remains:
At first, i thought N2Trader uses the "Close By" method iteratively to close all trades. but it seems it's not the case, because:
- N2Trader do this significantly fast
- as shown below, the log distinguish between "close by" and multiple close".
all this things suggest that THERE IS a multiple close! But how i can do this in programatically (in MQL4 language) by a EA?
The log of a "Close by" order for two trades (a buy is closed by a sell):
The log of a "Multiple close" order: