Lot Size Error

 
// Determine what a pip is.
   pips=Point; //.00001 or .0001. .001 .01.
   if(Digits==3 || Digits==5)

      pips*=10;

 

I get an invalid lot size error if I enter say 1.63 lot however if I enter 1.6 lot then I do not get an error message.

Please note that I am spread betting on fx is there a fix for my Pip sizing above or might the problem lie somewhere else in my EA?

Hope someone can suggest a fix thanks?? 

 
mickeyferrari:
// Determine what a pip is.
   pips=Point; //.00001 or .0001. .001 .01.
   if(Digits==3 || Digits==5)

      pips*=10;

 

I get an invalid lot size error if I enter say 1.63 lot however if I enter 1.6 lot then I do not get an error message.

Please note that I am spread betting on fx is there a fix for my Pip sizing above or might the problem lie somewhere else in my EA?

Hope someone can suggest a fix thanks?? 

What does your code have to do with lot size?

Maybe the symbol's lot step is 0.1, so anything smaller will be rejected.

 

As GumRai has pointed out, the volume or lots has nothing to do with pips or points (unless it is part of some unknown formula that you have not shown).

What is important, also pointed out by GumRai, is that your volume abide by the Broker's conditions of Minimum, Maximum and Step Size:

dblMarketLotMin  = MarketInfo( _Symbol, MODE_MINLOT  ); // Minimum Lots   allowed by Broker
dblMarketLotMax  = MarketInfo( _Symbol, MODE_MAXLOT  ); // Maximum Lots   allowed by Broker
dblMarketLotStep = MarketInfo( _Symbol, MODE_LOTSTEP ); // Lots Step Size allowed by Broker

// dblLotsCalculated = calculated volume based on risk, margin or other formula
// dblLotsNormalised = normalised volume based on broker's minimum, maximum and step size

dblLotsNormalised = fmin( fmax( round( dblLotsCalculated / dblMarketLotStep ) * dblMarketLotStep, dblMarketLotMin ), dblMarketLotMax );
 
Last line of my standard post
Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
 
WHRoeder:
Last line of my standard post - Lot size must also be adjusted to a multiple of LotStep. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
@WHRoeder, it may be advisable for you to update/revise your "NormalizeLots()" code at that post, because it is currently incomplete and does not check against the maximum number of lots ("MODE_MAXLOT").
Reason: