I want to know how to close the orders of same currency pair.
For example, There are three open orders.
1. EU buy order with TP/SL
2.GU sell order with TP/SL
3. EU sell order with TP/SL
4. UJ sell order with TP/SL
Once the #1 reach to TP, how can I close #3 also at the same time?
#3 does not still reach to TP/SL but I want to close together.
How can I code it?
void CloseOrder(int ClosePosition)
if(OrderMagicNumber()==MAGIC && OrderSymbol()==Symbol())
if(OrderType()==OP_SELL && ClosePosition!=1)
else if(OrderType()==OP_BUY && ClosePosition!=-1)
There are diffrent ways to do this but it depends, if you always have 4 open orders or if this is different
one way, you can check if the last cloed order reach the TP and then you can close all other one
an other way, if you always have 4 open orders, you can check how many open order you have and is this below 4 you can close the rest
in genreal, on OrderClose() you have to use bid and ask, bcs the OrderClosePrice is for the OrderHistory()
Not all brokers modify comments with TP. brokers can change
comments, including complete
Thank you for your comments.
I want to close the same current pair at the same time. If one order is closed with TP or SL, at the same time, same currency pair should be closed even it is loss.
I may check with using "for int " to find the same currency which is already ordered and close together. I will try..