double Lot()
{
double lot=Lots;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderProfit()>0)
{
lot=Lots;
break;
}
if(OrderProfit()<0)
{
lot=OrderLots()*KLot;
break;
}
}
}
}
if(CountTrades()>0)
{
lot=NormalizeDouble(Lots*MathPow(KLot,CountTrades()),2);
}
if(lot>MaxLot)
lot=Lots;
return(lot);
}
Najj