Download MetaTrader 5
To add comments, please log in or register
Do you know that MQL5 is an object-oriented language?
stargazer
149
stargazer 2011.10.26 10:42 

I have written this small function which helps any programs to do the normalize of prices (without having to re-type the long normalize command), but it keeps giving this error. How can i solve this?

//+------------------------------------------------------------------+
double normMe(string ins, double price){        
//+------------------------------------------------------------------+
        double dig=SymbolInfoInteger(ins,SYMBOL_DIGITS);
        
        return(NormalizeDouble(price,dig));
}

the error is: possible loss of data due to type conversion    tstEA.mq5    78    12

if theres any suggestion or work around to this? Thx!


Update: Now I do this (as below), and the error disappears!!. but is my solution below ok? Will it have any effects later, is what i am worried....

//+------------------------------------------------------------------+
double normMe(string ins, double price){        
//+------------------------------------------------------------------+
        int dig=(int)SymbolInfoInteger(ins,SYMBOL_DIGITS);
        
        return(NormalizeDouble(price,dig));
}
Alexey Da
Moderator
6538
Alexey Da 2011.10.26 10:52  

It isn't an error. It's just a warning.

I think this topic helps you

double normMe(string ins,double price)
  {
   int dig=(int)SymbolInfoInteger(ins,SYMBOL_DIGITS);
   return(NormalizeDouble(price,dig));
  }

 

stargazer
149
stargazer 2011.10.26 11:25  
alexvd:

It isn't an error. It's just a warning.

I think this topic helps you

 

Yes, i read 70-80% before, thats how I know to do that thing (int)...

int dig=(int)SymbolInfoInteger(ins,SYMBOL_DIGITS);

Thanks for letting me know its not error. Its a huge relief to me. This topic is solved, thanks to your reply.

/
To add comments, please log in or register