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) + ")");
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:
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?
Mark
Use StringConcatenate to avoid warnings.
IndicatorShortName( StringConcatenate( "Mark Hour GMT(", MarkHourGMT, ")" ));
Thanks Alexander.
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.?
Mark.
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:
DoubleToString
For datetime as i believe in your example:
TimeToString
it is all in the MQL4 reference
IndicatorShortName("Mark Hour GMT("+ TimeToString(MarkHourGMT) + ")");
Then TimeToString has also modes:
mode=TIME_DATE|TIME_MINUTES
[in]
Additional data input mode. Can be one or combined flag:
TIME_DATE gets result as "yyyy.mm.dd",
TIME_MINUTES gets result as
"hh:mm",
TIME_SECONDS gets results as "hh:mm:ss".
IndicatorShortName("Mark Hour GMT("+ TimeToString(MarkHourGMT,TIME_MINUTES) + ")");
Or you could type-cast:
IndicatorShortName("Mark Hour GMT("+ (string)MarkHourGMT + ")");
Or you could type-cast:
Thanks for expanding on this Marco. I have a huge task in front of me to learn C++.
implicit conversion from 'number' to 'strig'
what i have to type?
void myAlert(string type, string message)
{
if(type == "print")
Print(message);
else if(type == "error")
{
Print(type+" | KWM OSIA @ "+Symbol()+","+Period()+" | "+message);
}
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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?
Mark