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 );
To add comments, please log in or register