//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Lot(int type)
{
double lot=Lots;
lot=NormalizeDouble(Lots*MathPow(KLot,Losses()),2);
if(type>1)
lot*=KLot;
if(lot>MaxLot)
lot=Lots;
return(lot);
}
//+------------------------------------------------------------------+
//| Считает количество убыточных сделок в истории |
//+------------------------------------------------------------------+
int Losses()
{
int losses=0;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==0)
{
if(OrderOpenPrice()-OrderClosePrice()>0)
losses++;
if(OrderOpenPrice()-OrderClosePrice()<0)
break;
}
if(OrderType()==1)
{
if(OrderOpenPrice()-OrderClosePrice()<0)
losses++;
if(OrderOpenPrice()-OrderClosePrice()>0)
break;
}
}
}
}
return(losses);
}
AM2