Please teach OrderClose.

 
Three positions cannot be closed at a time.
Please teach the way that closes three positions.
 
namiko_ara wrote >>
Three positions cannot be closed at a time.
Please teach the way that closes three positions.

for example to close all open orders:

void  CloseAllCommon()
{ 
  for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) 
  { 
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); 
    
        OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),10,CLR_NONE);
        Sleep(100);
        }
}
if you want to close only three orders - you will have your reason - look for magic number, look for symbol, insert your own counter
 

it's not possible with : OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),10,CLR_NONE);

because OrderClosePrice() is the price when an order is already close !

You have to replace OrderClosePrice() with "Ask" or "Bid" after analysing OrderType()=="OP_BUY" or OrderType()=="OP_SELL"

 

It is certainly possible to close with OrderClosePrice(). It doesn't mean the order has to closed first for it to be valid.


The name of the function though is perhaps a bit ambiguous.

 
blogzr3 wrote >>

It is certainly possible to close with OrderClosePrice(). It doesn't mean the order has to closed first for it to be valid.

The name of the function though is perhaps a bit ambiguous.

That's a news for me :) OrderClosingPrice() would be less ambigous !

thanks