Download MetaTrader 5
To add comments, please log in or register
Need mobile version of MetaTrader 5? Download it and trade!
kasur
5
kasur 2011.01.07 06: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.

whroeder1
13630
whroeder1 2011.01.07 22: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());
}   }
/
To add comments, please log in or register