This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community
Closing half of the orderBack to topics list |
|
borko
2005.03.19 11:11
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. |
|
Slawa
2005.03.21 11:12
no problem. You can close positions partially. just do it.
|
|
borko
2005.03.31 13:13
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); } |
|
Slawa
2005.03.31 14:00
what is "does not work"?
you need to expose log records with errors. there may be severe reasons |
|
borko
2005.03.31 15:05
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". |
|
Slawa
2005.03.31 15:37
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! |
|
borko
2005.03.31 18:19
ERR_INVALID_TRADE_VOLUME 131 Invalid trade volume.
|
|
Slawa
2005.04.01 10:37
try to normalize your lot value
|
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets
