Download MetaTrader 5

type conversion...

To add comments, please log in or register


Why in a multi-pair EA this:


Gives me an error ""possible loss of data due to type conversion Malibu.mq4 426 111". (111= MarketInfo(pairmajeur,MODE_DIGITS));)


double take

int Take

string pairmajeur

This error did not appear in previous versions of the EA and appeared on the occasion of modifications which have nothing to do with the section of passage of the orders!

Thank you for your lights

Marco vd Heijden
Marco vd Heijden  

you can try several solutions to find the possible loss conversion.

Stuart Browne
Stuart Browne  

G'day stanislass

You're not getting an error, you're getting a compiler warning that something "could" go wrong, but always best to fix it.

  1. Know your return types. As Marco pointed out, you're returning a double for the last parameter but NormalizeDouble expects an int there
  2. Casting using (int), (double), (uchar) etc is quick & will get around compiler warnings but may eventually bite you in the bum (try dividing a double by an int). For numbers, try using the various Math functions first to explicitly convert values
  3. Using the same variable name with different capitalization will bite you in the bum VERY soon. If you must do it, try using variable names such as dblTake and intTake 
Hope that helps :)
To add comments, please log in or register