Hi,
I'm developing one EA that need to close 3 orders (same SYMBOL(), same PERIOD()) when the accumulated profit is positive.
No problem, the EA has one function that calculates the profit/loss of the 3 order, and if it reaches some amount of pips, closes the 3 orders.
My problem is...
is one of the orders stays open (requotes, trade context busy, etc) in the next tick, the profit will be negative and I lots the rigth momente to close the orders.
Is there a way to make sure that noting else is executed unless the 3 orders are closed?
Many thanks
SB
- How to check open orders and see if the balance of that order is positive or negative.
- Closing out half lots.
- Help with EA instant order requote problem!!
void CloseAll() {
for ( ... ) {
CloseOrder(...);
}
if (OrdersTotal()>0) CloseAll();
}
and one more method to reduce slippages - let say you want to close 3 buy orders of 0.2 lots, then it is better to open new sell order of 0.6 lots and then use OrderCloseBy() function to flat them out
bool OrderCloseBy( | int ticket, int opposite, color Color=CLR_NONE) |
Parameters:
ticket | - | Unique number of the order ticket. |
opposite | - | Unique number of the opposite order ticket. |
Color | - | Color of the closing arrow on the chart. If the parameter is missing or has CLR_NONE value closing arrow will not be drawn on the chart. |
Sample:
if(iRSI(NULL,0,14,PRICE_CLOSE,0)>75)
{
OrderCloseBy(order_id,opposite_id);
return(0);
}

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