Thread: How to code?
View Single Post
  #682 (permalink)  
Old 02-13-2008, 07:23 AM
k3iroll k3iroll is offline
Member
 
Join Date: Nov 2006
Posts: 90
k3iroll is on a distinguished road
Close all pending and open order when 1 trade hit TP

Hi,

I'm trying to write a codes in my EA that will close all pending and open orders once there is 1 trade that hit TP. Below is the codes that I used, seems not working. Can somebody take a look and advise what is missing. Thanks.


if( PreviousOpenOrders > OpenOrders )
{
for( cnt = OrdersTotal()-1; cnt >= 0; cnt-- )
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
mode = OrderType();
if( OrderSymbol() == Symbol() &&
OrderMagicNumber()==Magic)

{
if( mode == OP_BUY ) OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),slippage,Blue);
if( mode == OP_SELL ) OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),slippage,Red);
if (mode == OP_SELLLIMIT) OrderDelete(OrderTicket());
if (mode == OP_BUYLIMIT) OrderDelete(OrderTicket());

}
}
}
}
Reply With Quote