for (int i=0;i<OrdersTotal();i++)
i==6 and OrdersTotal()==6 => end of loop
mql_coder:
i==6 and OrdersTotal()==6 => end of loop
Thanks very much. I have been programming for 40 years but the brain must be wearing out. Ross
R
> ...I have been programming for 40 years...
Time for a break dude :)
-BB-
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi
I have been trying to get an EA working but for some reason when i go thru a for loop to close all my trades it only gets half of them. I have 12 trades and only 6 are closed. Is it a problem with my testing at every tick(only 2 days trading)? This is the non working routine
// This routine closes all open tradesint closeall()
{ Print(" oooot +++++++++++++++++++++ ",OrdersTotal());
for (int i=0;i<OrdersTotal();i++)
{int err;
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol()
&&OrderMagicNumber()==Magic)
{ Print(" ono ",OrderTicket()," i ",i);
if(OrderType()==OP_BUY)
{if(OrderClose(OrderTicket(),OrderLots(),Bid,0,Pink))
{continue;
}
else
{err =GetLastError();
Print("error ",err);
continue;
}
}//end of buy
if(OrderType()==OP_SELL)
{if(OrderClose(OrderTicket(),OrderLots(),Ask,0,Pink))
{continue;
}
else
{err = GetLastError();
Print("error ",err);
continue;
}
}//end of sell
}
else Print(" OrderSymbol ",OrderSymbol(), " om ",OrderMagicNumber());
}//end for
Print(" closed em all ",AccountEquity()," acb ",AccountBalance(), " i ",i);
return(0);
}
noranross@tadaust.org.au
Can someone please help???
Ross Darwin Australia