I try this cod:
if(usemnoznik)
{ prof=0;
for(int i=0; i < OrdersTotal(); i++)
{OrderSelect(i, SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
prof += OrderProfit();l=OrderLots();
if (prof>myprofit || prof<(endloss*(-1))){CloseAll();}
}
if (prof<(startloss*(-1))) Lots=mnoznik*l;else Lots=startlot;
}
......
void CloseAll()
{
for(int cc=0;cc<OrdersTotal();cc++)
{
if(OrderType()==OP_BUY || OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),10,CLR_NONE);
return(0);
}
}
}
but it isn't close my open orders.
I want close all open trades in that ea after profit > A or loss < B.But that part of code not working.
if last open trade is in loss, next should be open with lot*mnoznik and this ok.
can somebody look at this and advice ?
as i see it close only last trade,not all
how to do it ?



Reply With Quote

