Hi MQL4 forum.
I'v just started learning very simple MQL4 code and have converted a pre 2014 file to the current format. I've managed to work out all errors/warnings except "implicit conversion from 'number' to 'string' on Line 45 Market Hour GMT. Can someone please advise me what needs to be changed?
Compiler warns you that you are adding numbers and strings and that potentially there could be an error.
You need to explicitly tell compiler that you want strings to be concatenated - convert integer to string:
IndicatorShortName("Mark Hour GMT("+ IntegerToString(MarkHourGMT) + ")");
Use StringConcatenate to avoid warnings.
IndicatorShortName( StringConcatenate( "Mark Hour GMT(", MarkHourGMT, ")" ));
So either of these two options work in my example. Would the function IntegerToString only work in specific instances where you start off with an integer but Concatenate would work with doubles, integers, etc.?
It's a warning not an error.
When you convert a double to integer it will warn you about the data loss since integer can only be a whole number and it will simply cut off the numbers after the . so for example double 10.34 simply becomes 10 when converted to integer.
For double you use:
For datetime as i believe in your example:
it is all in the MQL4 reference
IndicatorShortName("Mark Hour GMT("+ TimeToString(MarkHourGMT) + ")");
Then TimeToString has also modes:
Additional data input mode. Can be one or combined flag: TIME_DATE gets result as "yyyy.mm.dd",
TIME_MINUTES gets result as
TIME_SECONDS gets results
IndicatorShortName("Mark Hour GMT("+ TimeToString(MarkHourGMT,TIME_MINUTES) + ")");
Or you could type-cast:
IndicatorShortName("Mark Hour GMT("+ (string)MarkHourGMT + ")");