double LotByRisk(string pair)
{
if(InpRisk <= 0)
return(Lot);
double Free = AccountInfoDouble(ACCOUNT_MARGIN_FREE);
double LotVal = SymbolInfoDouble(pair,SYMBOL_TRADE_TICK_VALUE);
double Min_Lot = SymbolInfoDouble(pair,SYMBOL_VOLUME_MIN);
double Max_Lot = SymbolInfoDouble(pair,SYMBOL_VOLUME_MAX);
double Step1 = SymbolInfoDouble(pair,SYMBOL_VOLUME_STEP);
double slpss=stopLoss;
if(slpss<=0)
slpss=1000;
if(LotVal<=0)
LotVal=1;
double max_risk = InpRisk;
double Lotss=MathFloor((Free*max_risk/100)/(slpss*LotVal)/Step1)*Step1;
Lotss = NormalizeDouble(Lotss,LotDigitsPair);
if(Lotss<Min_Lot)
Lotss=Min_Lot;
if(Lotss>Max_Lot)
Lotss=Max_Lot;
return(Lotss);
}