Does your broker allow partial order closing? If not instead of opening 1 position for x lots open 2 positionns x/2 lots each.
for your further reference see this thread:
https://forum.mql4.com/4435#13901
https://forum.mql4.com/4435#13901
LesioS:
Does your broker allow partial order closing? If not instead of opening 1 position for x lots open 2 positionns x/2 lots each.
Does your broker allow partial order closing? If not instead of opening 1 position for x lots open 2 positionns x/2 lots each.
Many thanks for your input - yes the broker (Interbank FX) does allow partial order closing - I can take the exact trade manually that I'm trying to execute with code. Essentially I'm opening long 0.5 mini lots (testing size) and then closing 0.1 mini lot. Works fine in manual trade. The function just will not pick up the lot size required and is still defaulting to the lots I have open - i.e. it's trying to close the whole order.
Here is the line of code:
OrderClose(OrderTicket(),0.1,Bid,3,Red);
Many thanks for any further help you can give.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Could you please help me with the following requirement for an Expert Advisor:
I have an open order, which has a Stop Loss. I want to exit 1/2 the poistion at Profit Target 1, and exit the other half at Profit Target 2.
I have a long order open for 2 lots. To close the first half of the order I've been trying to use the function:
if (Bid > EntryPrice + (Point*30)) { OrderClose(TicketNo,1,Bid,3,Red);}
So this should exit 1 of the 2 lots (half the order) if the bid goes above an inputed EntryPrice + 30 points.
I have manual confirmations switched on in Expert advisor. What I'm finding is that when this condition is triggered the order confirmation screen tries to exit 2 lots (the whole position), rather than just 1/2 of it.
Am I taking the correct approach? I don't want to take the approach of opening 2 orders and managing them seperately as this makes the code more complex and I have 2 orders to reconcile. Could you please advise if above general approach should work and why OrderClose is ignoring the lot size I am putting in?
Many thanks.