Close all order at once - Not thru looping opening order - page 2

 

Ther is no way to close multiple positions at once.

There is a way to close all orders in the same direction on the same symbol with only 1 (actually 2 but the second can be done at leisure time) OrderSend.

-Calculate the total volume. 

-Send opposite order with calculated volume.

-Use CloseBy to collapse both positions. No need to hurry here, this can be done at the next tick or when spread is lower, whatever logic suits your needs.

Things to note are:

-You must check if you have enough margin for opening the opposite position.

- Make sure your broker allows CloseBy (some popular brokers have this disabled, it is clear these brokers need to be avoided). 

 
Enrique Dangeroux #:

Ther is no way to close multiple positions at once.

There is a way to close all orders in the same direction on the same symbol with only 1 (actually 2 but the second can be done at leisure time) OrderSend.

-Calculate the total volume. 

-Send opposite order with calculated volume.

-Use CloseBy to collapse both positions. No need to hurry here, this can be done at the next tick or when spread is lower, whatever logic suits your needs.

Things to note are:

-You must check if you have enough margin for opening the opposite position.

- Make sure your broker allows CloseBy (some popular brokers have this disabled, it is clear these brokers need to be avoided). 

Yes, the method freezes the "profit/loss", so that you can then close the orders slowly and at leisure irrespective of delays without affecting the frozen gain.

This obviously has some limitations and conditions but the OP would be wise to learn this processing method as a workaround instead of insisting that it "can be done (closing all at once)" and that he saw it happen and therefore it MUST be true.

 

\Most likely what he saw was the time the broker closed the positions. This can happen in batches and can be very fast.

Off course the orders sent to close the positions could be with just 1 OrderSend at a time. In other words you can not conclude the orders where instantly closed at once with 1 order just by looking at the broker time. Sometimes ignorance is not bliss :)


Anyhow, i think CloseBy method is faster then async close for every position with large number of positions.

 
Enrique Dangeroux #: -Use CloseBy to collapse both positions.

Which will not work with US brokers. Since 2009, hedging is not permitted for US traders.
          NFA Enforces FIFO Rule, Bans Forex Hedging in US Forex Accounts - Trading Heroes (September 12, 2016)
          FAQ: FIFO in the Forex Market - BabyPips.com (May 31, 2011)

 
William Roeder #: Which will not work with US brokers. Since 2009, hedging is not permitted for US traders.

          NFA Enforces FIFO Rule, Bans Forex Hedging in US Forex Accounts - Trading Heroes (September 12, 2016)
          FAQ: FIFO in the Forex Market - BabyPips.com (May 31, 2011)

Yes, we are well aware that it will not work in the US, but the world is much, much larger the the USA. It is common practice to generalise things in favour of the majority instead of the minority, and the majority have no such limitations.

Reason: