Wrong character
↑
- 2024.09.20
- www.mql5.com
Thanks, but it did not help much.
So, what's the solution? As I said, I don't want to use Wingdings.
Note that this diagnostic response may be unique to my terminal/MetaEditor settings. If yours are the same, here you go.
MT5 AI Assistant
Cause
The font is a red herring — by the time the text reaches the terminal it probably isn't ↑ (U+2191) any more, it's already ? (U+003F). ObjectSetString(..., OBJPROP_TEXT, ...) can only draw what's in the string, and both Segoe UI Symbol and Arial do contain U+2191, so changing the font can't help.
That single ? is the classic signature of a lossy code-page conversion of the string literal, not of a bad glyph at render time. The usual trigger is a source file stored in an ANSI/legacy code page (e.g. Windows-1252) or the character having been pasted through a step that dropped it: U+2191 has no mapping in CP1252, so it is replaced by one ? . MetaEditor even warns about this when saving a file in such an encoding.
What I verified in your terminal
I compiled and ran a throwaway test script (deleted afterwards, no existing file touched) with a UTF-8 source file, build 6361:
literal: len=1 codes=U+2191 generated: len=1 codes=U+2191and both OBJ_BUTTON s came back from the terminal with description: "↑" . So the whole chain — compiler → OBJPROP_TEXT → button — works fine when the source bytes actually arrive as U+2191. Which means the character is being lost before the terminal sees it, i.e. in your file's encoding (ANSI) or in whatever produced that literal.
Quick 1-line confirmation, add right after ObjectSetString :
Print("len=", StringLen(ObjectGetString(0, name, OBJPROP_TEXT)), " cp=", StringGetCharacter(ObjectGetString(0, name, OBJPROP_TEXT), 0));
- cp=63 (or len=0 ) → the string is already broken, exactly as above.
- cp=8593 (= 0x2191) → the string is fine and the problem would be on the drawing side (wrong/invisible font name), which your test with Arial largely rules out.
Fix — build the character from its code point
This is the robust fix: the source stays pure ASCII, so no editor, locale, or code-page setting can mangle it.
// ObjectSetString(0, name, OBJPROP_TEXT, "↑"); // loses the glyph in an ANSI file ObjectSetString(0, name, OBJPROP_TEXT, ShortToString(0x2191)); // U+2191 ↑ built at runtimeEquivalent alternative, if you prefer a literal: use the escape sequence, which is also pure ASCII in the source:
ObjectSetString(0, name, OBJPROP_TEXT, "\x2191"); // U+2191 ↑If you'd rather keep the visible ↑ in the source, then fix the file encoding instead: in MetaEditor use File → Save As and pick UTF-8 (or UTF-16), and set the default under Tools → Options → General → Default encoding. Your IDE default is already utf-8 , so a file saved earlier as ANSI is the likely culprit.
Notes
- No Wingdings needed, and nothing else in your function is wrong: corner, sizes, colors, OBJPROP_STATE , HIDDEN , and the ChartRedraw call are all fine. The button centers its text, so with height = 30 and FONTSIZE = 18 the arrow fits.
- For crisp small-size arrows/triangles, U+25B2 "▲" / U+25BC "▼" exist in virtually every font; 0x2191 is fine with Segoe UI Symbol .
- If you want a shape rather than a glyph, an OBJ_ARROW_UP object positioned over the button is an alternative, but the code-point fix above keeps your current design.
- Verification artifacts: I opened a temporary EURUSD H1 chart, ran the test script, then closed the chart and removed the temp .mq5 / .ex5 / .png . No pre-existing file was modified.
Hi there!
This code is supposed to display an upward-pointing arrow on the button, but I'm only getting a question mark.
I also tried using Arial, but that didn't work either.
I don't want to use Wingdings on purpose.
What's the cause, and how can I fix it?