Partial close for a BUY order

 

Hi,

For my EA, I try to close an order with 2 partial close but without success.

I would like to send two OP_SELLLIMIT to close a BUY order (with specifics volume and price for each sell limit order), how to proceed?

The problem is the ticket number of my BUY order, my sell limit order must have the same ticket number than my BUY order, how to send a sell limit order with the same BUY ticket number?

I don't want to use OrderClose() to close my BUY order but sell limit orders.

Thank you for your help.

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Requests to execute trade operations are formalized as orders. Each order has a variety of properties for reading. Information on them can be obtained using functions Position identifier that is set to an order as soon as it is executed. Each executed order results in a deal that opens or modifies an already existing position. The identifier of...
 

To (partially) close a position with opposite direction you need a netting account. On hedge you need to use CloseBy.

Closing a position with a limit order exposes you to the risk of not getting filled.

 
Enrique Dangeroux:

To (partially) close a position with opposite direction you need a netting account. On hedge you need to use CloseBy.

Closing a position with a limit order exposes you to the risk of not getting filled.

Thank you for your answer.

I found a solution at my problem:

- I open 2 orders Buy (for example with 0.01 each lot) with 2 Take Profit differents: the first TP correspond at my first close (partial) and the second TP correspond at the second close.

Reason: