Reduce (partial close) a position using a SL or TP

 
Dear all,

I started working on an EA the other day and I'm blocked at a certain point.
I want to do a partial closing on a position using an SL or a TP, but I can't figure out how to do this.

For instance, I open a 5 lots position:
int ticket=OrderSend(Symbol(),OP_SELL,5.0,Bid,0,0,0,"First trade",0,0,Red);

Then I want to reduce this position by 2 lots if the market moves to a certain point.
And here I don't know what to do because the 2 functions I know to do that are OrderModify() and OrderClose().
But none of them allows me to do this.
OrderModify allows me to close the entire position with a SL/TP
OrderClose allows me to reduce the position but not to place SL/TP.
What I need to do is to combine both ;)

I would really appreciate any help on this.
Thanks in advance

Isma
 
ismail.hussein:
(...)
OrderModify allows me to close the entire position with a SL/TP
OrderClose allows me to reduce the position but not to place SL/TP.
What I need to do is to combine both ;)

SL/TP works on the entire position only. There is no partial close using SL/TP. Your can close the position partially using OrderClose() and use OrderModify() to set SL/TP for the remaining open position.

 
Well, what I wanted to do is to realize enough gains on part of the position by placing an SL or TP on part of it.
And keep the rest in case the market is favorable...

So there's no way to do this?
 
ismail.hussein:
Well, what I wanted to do is to realize enough gains on part of the position by placing an SL or TP on part of it.
And keep the rest in case the market is favorable...

So there's no way to do this?

Not with a single position. U can open 2 smaller positions initially and then set different SL/TP for each.

 
OK, thanks for your help!

Are you aware of MT5? I've heard that functions to reduce, increase, ... have been added, right?
 
ismail.hussein:
OK, thanks for your help!

Are you aware of MT5? I've heard that functions to reduce, increase, ... have been added, right?

It's completely different than MT4. You can read about it here:

http://mqlmagazine.com/leading-article/orders-positions-and-deals-part-i/

http://mqlmagazine.com/mql-programming/orders-positions-and-deals-part-ii/

 
you can do it with MQL4.

use orderclose but the lot size u put it lesser
Reason: