Issue with wrong lot size

Enrique Dangeroux  

https://www.mql5.com/en/forum/192920

Error code Ordersend error 131
Error code Ordersend error 131
  • 2017.05.19
  • www.mql5.com
Dear Friends I just build an EA for autotrade. But I cant upload it to Market due to this Error 131 occur. Please help me to resolve this...
Mihkelt  
EnriqueD:

https://www.mql5.com/en/forum/192920


This offers no help though to my case?

Or if you're trying to say for me to search for answers before posting, then I did. I would understand this if I just asked what error 131 is, but I'm more specifically asking how can it be that minlot is 0.01 and lotstep and maxlot both 0 and what it means, which is a different question IMO and one that I can't find an answer to nowhere. 

Alain Verleyen  
Mihkelt:

This offers no help though to my case?

Or if you're trying to say for me to search for answers before posting, then I did. I would understand this if I just asked what error 131 is, but I'm more specifically asking how can it be that minlot is 0.01 and lotstep and maxlot both 0 and what it means, which is a different question IMO and one that I can't find an answer to nowhere. 

If you don't get the correct values, either there is a bug in your code or it may happen the broker don't provide them.

Show your code and/or ask to your broker.

And it's always a good idea to search for answers before posting :-)

fxsaber  
double CorrectLot( const double Lot )
{
  static const double StepVol = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
  static const double MaxVol = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
  static const double MinVol = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);

  const double Vol = StepVol * (int)(Lot / StepVol + 0.5);

  return((Vol < MinVol) ? MinVol : ((Vol > MaxVol) ? MaxVol : Vol));
}