View Single Post
  #10  
Old 30-03-2009, 13:04
pippimp pippimp is offline
Level 1 Lasers Member
 
Join Date: Mar 2009
Posts: 10
Default Here it is

Cwave,

My buddy said insert this code into the EA and it should do the trick..

Put this function into your EA and the calls of it in places where are signals for enter new position:

CloseAll(OP_BUY, MagicNumber, Symbol());
CloseAll(OP_SELL, MagicNumber, Symbol());

//-------------------------------------------------------------------------------------------
void CloseAll(int type, int MagicNumber, string symbol="")
{
int i;

if (StringLen(symbol)==0) symbol = Symbol();
for(i = OrdersTotal()-1; i >= 0; i--)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==symbol && OrderMagicNumber()==MagicNumber && OrderType() == type)
{
OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3);
}
}
}
//-------------------------------------------------------------------------------------------
Reply With Quote