Close All order and pending order if one of the order is take profit

Back to topics list To post a new topic, please log in or register
avatar
1
kasur86 2011.01.07 07:01
 

Hi Guys,,apologize me if my english is bad,,I'm from Indonesia,,and I want to make an EA but I got the problem

How to close all opened order and all pending order if one of the opened order is already take profit?

I'm very appreciate for all the forum to help me :D thanks.

 
avatar
12985
WHRoeder 2011.01.07 23:47 #
 
How to close all opened order and all pending order if one of the opened order is already take profit?
Do you really want to close the one order that is one pip in profit? Anyway something like this:
    for(int inProfit = OrdersTotal()-1; pos >= 0 ; pos--) if (
        OrderSelect(inProfit, SELECT_BY_POS)         // Only my orders w/
    &&  OrderMagicNumber() == magic.number           // my magic number
    &&  OrderSymbol()      == Symbol()               // and symbol
    &&  OrderProfit()       > 0 ){
        CloseAll(); break;
    }
...
void CloseAll(){
    for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
        OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
    &&  OrderMagicNumber() == magic.number              // my magic number
    &&  OrderSymbol()      == Symbol() ){               // and symbol
        if (OrderType()< OP_SELL) 
           OrderClose(OrderTicket(), OrderLots(), OrderClose(), Slippage.Pips*pips2points,  Aqua );
        else
           OrderDelete(OrderTicket());
}   }

 
Back to topics list  

To add comments, please log in or register