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.
Thank you for your detailed help.
You're welcome.
Unfortunately, I couldn't solve the problem with these things.
I probably should have told the Assistant to save the script. Anyway, here's its dialogue, followed by the test script.
Again, the Assistant worked based on my system including a widescreen and high resolution display. You may need to do some tweaking to reposition the object or get it to show whatsoever.
MT5 AI Assistant
Done.
What is not the cause: the font
I tested your exact snippet in your own terminal (build 6361) and measured the rendered pixels:
Font Arrow drawn? Segoe UI Symbol yes Segoe UI yes Arial yes Tahoma yes U+2191 is present in Arial, Segoe UI and Segoe UI Symbol, so the font choice was never the blocker — and Wingdings is not needed. (Wingdings keeps its arrow at 0xE9 , an ANSI-range byte; that's why the old trick floats around on forums: it survives ANSI files and is a compact glyph. It's a workaround for two unrelated problems, not a requirement.)
Also verified: the literal "↑" in a UTF-8 source compiles to the same string as a runtime-built one — len=1, codepoint=U+2191 .
What is actually wrong
Two failure modes, both independent of the font:
- OBJ_BUTTON clips its text to the object rectangle, and your 18 pt glyph does not fit in 30 px. Measured on your 40×30 / 18 pt button: the glyph ink spanned y = 25…51 while the button spanned y = 20…50 — a 1 px overflow at 100 % scaling. As soon as anything squeezes it a bit more (Windows display scaling ≠ 100 %, a different theme/DPI, a font with taller ascent), the whole glyph falls outside the clip rect and you see an empty button, not a truncated one. That is why changing the font changed nothing: Arial's arrow is the same height.
- The character can be destroyed before it is ever drawn. If the .mq5 file is saved as ANSI/CP1251, ↑ cannot be stored and becomes ? or garbage at save time — no OBJPROP_FONT can repair that. Reading back the object text is the discriminator: len=1 + U+2191 means the string is fine and the problem is geometry; len=3 or a different code point means the file encoding ate the character.
The fix
Build the code point at run time (source stays pure ASCII, so file encoding can never corrupt it) and give the glyph room:
#define UP_ARROW 0x2191 // Unicode "↑" ObjectSetString(0, name, OBJPROP_TEXT, ShortToString(UP_ARROW)); ObjectSetString(0, name, OBJPROP_FONT, "Segoe UI Symbol"); ObjectSetInteger(0, name, OBJPROP_FONTSIZE, 16); // keep <= height - 14Measured fit on your machine: 16 pt in 34 px, 12 pt in 30 px, 9 pt in 30 px all render fully; 18 pt needs ≥ 34 px of height.
Changed:
- MQL5\Scripts\UpArrowButton.mq5 (new file — no existing file was touched): your function with ShortToString(0x2191) , Segoe UI Symbol , default size 44×34 @ 16 pt, plus a OnStart() demo that prints the stored code point for self-checking.
Validation:
- Compilation: 0 errors, 0 warnings ( UpArrowButton.mq5 ).
- Runtime: journal printed created MA_UpArrowButton: len=1 codepoint=U+2191 .
- Rendering: captured the chart and mapped the button pixels — full arrowhead + stem, entirely inside the rectangle:
y=29 |................... ###...................| y=32 |................ ######### ...............| y=34 |.............. ###. ###. ### .............| y=38 |................... ###...................| y=52 |................... ###...................|
Commands used:
- powershell ... System.Drawing ... GetPixel on MQL5\Files\*.png : count/map glyph pixels to prove the arrow is drawn; read root MQL5 .
Notes:
- Diagnostic script and all screenshots were deleted. A temporary EURUSD,H1 chart (chart03) is still open showing the live demo button — close it when you're done.
- If you must keep 40×30, set OBJPROP_FONTSIZE to 12–14; do not keep 18.
- If the arrow still doesn't appear after this change, check that your program was recompiled and the old .ex5 is not still running — a stale binary is the third classic reason a code change has no visible effect.
- If you ever need this to survive arbitrary DPI scaling, draw the triangle as a separate OBJ_ARROW / OBJ_BITMAP_LABEL instead of a text glyph; say the word and I'll add that variant (emphasis added).
Thank you so much for your help.
I didn't make it clear—since I posted on the MT4 forum—but I'm talking about MT4, not MT5.
In any case, I tried your script on both; on MT5, I also get the upward-pointing arrow, but on MT4, only the question mark still appears. I have no idea why.
I got these print statements:
MT5 >> created MA_UpArrowButton: len=1 codepoint=U+2191
MT4 >> created MA_UpArrowButton: len=1 codepoint=U+003F
I added the following to the code:
string arrow = ""; StringSetCharacter(arrow, 0, 0x2191); PrintFormat("before: len=%d codepoint=U+%04X", StringLen(arrow), (int)StringGetCharacter(arrow, 0)); ObjectSetString(0, name, OBJPROP_TEXT, arrow); string txt = ObjectGetString(0, name, OBJPROP_TEXT); PrintFormat("after: len=%d codepoint=U+%04X", StringLen(txt), (int)StringGetCharacter(txt, 0));
According to the AI: StringSetCharacter() correctly generates the U+2191 character, but when MT4 passes the text to OBJ_BUTTON or OBJ_LABEL, it replaces it with a ?. Therefore, this is not a font issue, and no improvement can be expected from changing the way the character is generated.
The MT4 terminal’s graphical interface does not handle certain Unicode characters reliably; although the MT4 documentation allows you to set the text for an OBJ_BUTTON, this does not guarantee that all Unicode characters will pass through the terminal’s display layer.
So, I think it is a BUG in MT4.
According to the AI: StringSetCharacter() correctly generates the U+2191 character, but when MT4 passes the text to OBJ_BUTTON or OBJ_LABEL, it replaces it with a ?.
My bad. I failed to realize that we're in the MT4 subforum.
Anyway, the MT5 AI Assistant confirms what you said:
Blocking issue (MT4 terminal behavior, not MQL4 code):
- ObjectSetString(…, OBJPROP_TEXT, …) in MT4 hands the text to the terminal as a single-byte ANSI (CP_ACP) string. The MQL4 string is UTF-16 internally — that is why StringSetCharacter() / ShortToString() give you a correct U+2191 — and the loss happens at the MQL4 → chart-object boundary, before the font is consulted.
- Consequence: OBJPROP_FONT is irrelevant. Segoe UI Symbol does contain U+2191 , yet MT4 still prints ? , because the character is already gone when the renderer sees the text. Same for OBJ_LABEL , OBJ_EDIT , OBJ_BUTTON .
- The ANSI code page ( 1252 , 1251 , …) contains no arrow code points, so no code point trick, encoding trick or StringSetCharacter() variant can put U+2191 into MT4 object text. Verified as a property of the platform, not of this script.
So the set {MT4, OBJ_BUTTON/OBJ_LABEL text, no symbol-font glyph, no bitmap/image} is empty. There is no fourth text path.
What is actually left, all MT4-legal:
Option Arrow quality Cost A. Geometric arrow: 1 textless OBJ_BUTTON + OBJ_RECTANGLE_LABEL slices forming shaft + staircase triangle head Blocky edges (1–2 px steps at 44×34) ~12–14 objects, click routing must be checked B. Plain-ASCII approximation, e.g. "^" over "|" , or text "UP" Not a real arrow Trivial, zero risk — but no glyph C. Non-Wingdings symbol font ( Webdings , Marlett ) with an ANSI-range code Crisp Still a symbol font — the thing you just excluded D. Bitmap / OBJ_BITMAP_LABEL Perfect, any shape/colour Excluded by you My recommendation if the goal is "arrow, no Wingdings, no image": A — it is the only option that renders an actual arrow and touches no font at all. It is also the only one I can write in a way that survives a system without symbol fonts. It is genuinely worse-looking than the glyph, so it needs your go-ahead before I restructure the script.

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?