Closing half of the order

 
Is it posible to close half of the order instead of having two orders and close one of them.
Example: An expert script opened position with 1lot, if profit is 50pips I want to close 0,5lots
and leave the other 0,5lots running.
 
no problem. You can close positions partially. just do it.
 
OK, but the next code does not work!

if ((OrderProfit()/(Lots*10)>=30)&&(OrderLots()==Lots))
{
if (OrderType()==OP_SELL)
OrderClose(OrderTicket(),OrderLots()/2,Ask,Slippage,Red);
else
OrderClose(OrderTicket(),OrderLots()/2,Bid,Slippage,Red);
}
 
what is "does not work"?
you need to expose log records with errors. there may be severe reasons
 
I mean there is no error in the logs and no trade is closed(half of the lot).
If I use this one on usdjpy:

if ((OrderProfit()/(Lots*10)>=30)&&(OrderLots()==Lots))
{
Print(OrderSymbol());
if (OrderType()==OP_SELL)
OrderClose(OrderTicket(),OrderLots()/2,Ask,Slippage,Red);
else
OrderClose(OrderTicket(),OrderLots()/2,Bid,Slippage,Red);
}
The only thing that is printed in logs is "usdjpy".
 
did You check last error after closing? I see You don't check both operation's result and last occured error.
please study our script samples!
 
ERR_INVALID_TRADE_VOLUME 131 Invalid trade volume.
 
try to normalize your lot value
Reason: