Lot Size Error

Back to topics list To post a new topic, please log in or register
avatar
44
mickeyferrari 2016.05.22 23:58
 
// 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?? 

avatar
Moderator
3418
GumRai 2016.05.23 01:04 #
 
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.

avatar
1217
FMIC 2016.05.23 03:23 #
 

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 );


avatar
13004
WHRoeder 2016.05.23 18:12 #
 
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

avatar
1217
FMIC 2016.05.23 18:26 #
 
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").
Back to topics list  

To add comments, please log in or register