There is no mistake. Reference: ColorToString
Parameters
color_value
[in] Color value in color type variable.
color_name
[in] Return color name if it is identical to one of predefined color constants.
Return Value
String presentation of color as "R,G,B", where R, G and B are decimal constants from 0 to 255 converted into a string. If the color_name=true parameter is set, it will try to convert color value into color name.
Therefore, the function ALWAYS returns the NAME of the color. But if true, an attempt is made to convert the color value to a color name.

- www.mql5.com
There is no mistake. Reference: ColorToString
Parameters
color_value
[in] Color value in color type variable.
color_name
[in] Return color name if it is identical to one of predefined color constants.
Return Value
String presentation of color as "R,G,B", where R, G and B are decimal constants from 0 to 255 converted into a string. If the color_name=true parameter is set, it will try to convert color value into color name.
Therefore, the function ALWAYS returns the NAME of the color. But if true, an attempt is made to convert the color value to a color name.
ALWAYS?????
No, only if the color_name=true parameter is set.
In the code I set it to false.
You are confusing two concepts: color name and color constant.
To be honest, I generally think that the bool parameter is NOT NECESSARY.
You are confusing two concepts: color name and color constant.
To be honest, I generally think that the bool parameter is NOT NECESSARY.
I agree.
Thanks anyway
I agree.
Thanks anyway
Isn't it hard for you to tell which cases you use the ColorToString () function?
No problem.
I use it to save settings on file (I convert colors to strings first).
string str_clr = ColorToString(colorUp,false); str_size = StringLen(str_clr); FileWriteInteger(file_handle, str_size, INT_VALUE); FileWriteString(file_handle, str_clr, -1);
Opposite conversion when reading back from files
There is no mistake. Reference: ColorToString
Parameters
color_value
[in] Color value in color type variable.
color_name
[in] Return color name if it is identical to one of predefined color constants.
Return Value
String presentation of color as "R,G,B", where R, G and B are decimal constants from 0 to 255 converted into a string. If the color_name=true parameter is set, it will try to convert color value into color name.
Therefore, the function ALWAYS returns the NAME of the color. But if true, an attempt is made to convert the color value to a color name.
You are wrong, according to the documentation it's clearly a bug.
Print(ColorToString(C'0,255,0',false)); // Should return "R,G,B", so "0,255,0"
It returns :
2021.04.30 01:26:43.528 te (EURUSD,M5) clrLime
I think that the function works correctly without the participation of the 'bool' parameter - the function tries to return the name of the color, if there is no such color (such a color constant), then the output will be in the form of RGB.
Example:
string clr=ColorToString(C'0,254,0'); // color Print(clr); clr=ColorToString(C'0,255,0'); // color Print(clr);
Result:
0,254,0 clrLime

- 2021.04.30
- www.mql5.com
You are wrong, according to the documentation it's clearly a bug.
It returns :
2021.04.30 01:26:43.528 te (EURUSD,M5) clrLime
What I thought too (beyond the usefulness of the second parameter).
thank you both

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everybody,
I have a problem with the ColorToString () function.
The second parameter is ignored. I set it to false but the function still returns the color name.
This the result in debug