Download MetaTrader 5

OrderClose - all lots and ignore slippage

To add comments, please log in or register
Do you have Linux? Find out how to install MetaTrader on it!
mop0
197
mop0 2014.01.31 18:21 

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
18001
Simon Gniadkowski 2014.01.31 18:25  
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 2014.01.31 18:30  

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
18001
Simon Gniadkowski 2014.01.31 20:06  
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
14518
whroeder1 2014.01.31 20:13  
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