Download MetaTrader 5

OrderClose - all lots and ignore slippage

To add comments, please log in or register
mop0
197
mop0  

I want to close a position entirely. It does not matter what its lot size, slippage or whether it is long or short. What parameters should I put in? Would 0 work?

OrderClose(OrderTicket(),0,0,0,Violet); 
Simon Gniadkowski
Moderator
18046
Simon Gniadkowski  
eempc:

I want to close a position entirely. It does not matter what its lot size, slippage or whether it is long or short. What parameters should I put in? Would 0 work?

You have to do what the Documentation says . . . OrderClose() the color parameter is optional, the rest aren't. Select the Order then you can use OrderLots(), OrderClosePrice() and OrderTicket()
mop0
197
mop0  

I was hoping the default settings of 0 could just ignore the parameter and close off completely.

Lot sizes are determined in relation to account size (which obviously changes) so I guess I will have to record the lot size at the time the order opened, and then write a separate OrderClose for longs and shorts.

Simon Gniadkowski
Moderator
18046
Simon Gniadkowski  
eempc:

I was hoping the default settings of 0 could just ignore the parameter and close off completely.

Lot sizes are determined in relation to account size (which obviously changes) so I guess I will have to record the lot size at the time the order opened, and then write a separate OrderClose for longs and shorts.

Erm . . . as I said,

Select the Order then you can use OrderLots(), OrderClosePrice() and OrderTicket()

whroeder1
16555
whroeder1  
eempc: I want to close a position entirely. It does not matter what its lot size,
You must put the full order size (OrderLots) to close entirely. Zero would mean close nothing.
To add comments, please log in or register