implicit conversion from 'number' to 'string' warning

To add comments, please log in or register
Dale Forsyth
71
Dale Forsyth  

Hi all,

I have an EA that has been converted from mql4 to mql5. When I compile the code in MetaEditor I am getting an error that states this

implicit conversion from 'number' to 'string'

I believe that the issue has something to do with a coding error that may not have been an issue in mql4 but now poses a problem on mql5. File is attached.

I would really be grateful if there is an individual that would be willing to take a look at the problem and possibly rectify the problem. I am certain that it will be a very simple solution, though I am still building my skills and understanding of mql5 so I am not clever enough to fix it myself yet.

Thankyou.


implicit conversion from 'number' to 'string' selflearningexperts.mq5 432 15


Files:
Petr Nosek
1259
Petr Nosek  
Dale Forsyth:

Hi all,

I have an EA that has been converted from mql4 to mql5. When I compile the code in MetaEditor I am getting an error that states this

implicit conversion from 'number' to 'string'

I believe that the issue has something to do with a coding error that may not have been an issue in mql4 but now poses a problem on mql5. File is attached.

I would really be grateful if there is an individual that would be willing to take a look at the problem and possibly rectify the problem. I am certain that it will be a very simple solution, though I am still building my skills and understanding of mql5 so I am not clever enough to fix it myself yet.

Thankyou.


implicit conversion from 'number' to 'string' selflearningexperts.mq5 432 15


It isn't an error just a warning. You can:

  1. Ignore it
  2. Delete the line 432, because it doesn't have an impact to result
  3. Instead of Print("h="+h) you can you use for example printf("h=%d",h)
Genesis Hafalla
8915
Genesis Hafalla  
Dale Forsyth:

implicit conversion from 'number' to 'string' 


use DoubleToStr()

Print("h="+DoubleToString(h)) ;

Demos Stogios
225
Demos Stogios  
Also, you can use a cast, like : Print("h="+(string)h). OTOH DoubleToString() can give some options
Petr Nosek
1259
Petr Nosek  
I recommend deleting that whole line (432) because I'm sure you do not need to see anything like "h=21354" in the terminal. Where 21354 is a file handle. I think the line is the rest of the program debugging that the programmer has forgotten there. Maybe you should add checking in the code (if(h<0)) if the file has opened successfully.
To add comments, please log in or register