Short answer: limit object names and text to a maximum of 63 characters.
This script builds off your example and shows what happens when you try to exceed 63 characters for the name or text:
#include <stdlib.mqh> int start() { // Works, no truncation WriteLN( "A", "NA1234567890123456789012345678901234567890123456789012345678901", // name = 63 Characters "TA1234567890123456789012345678901234567890123456789012345678901", // text = 63 Characters Red, 0, 50); // name is truncated to 63 characters, object can't be found when called with 64 character name WriteLN( "B", "NB12345678901234567890123456789012345678901234567890123456789012", // name = 64 Characters "TB1234567890123456789012345678901234567890123456789012345678901", // text = 63 Characters Yellow, 0, 100); // text is truncated to 63 characters WriteLN( "C", "NC1234567890123456789012345678901234567890123456789012345678901", // name = 63 Characters "TC12345678901234567890123456789012345678901234567890123456789012", // text = 64 Characters Lime, 0, 150); } void WriteLN(string trial, string name, string text, color clr, int xDist, int yDist) { if (ObjectFind(name)==-1) ObjectCreate(name, OBJ_LABEL, 0,0,0); Print(trial, "-Create: ", ErrorDescription(GetLastError())); ObjectSetText(name,text,10,"Courier New",Moccasin); Print(trial, "-SetText: ", ErrorDescription(GetLastError())); ObjectSet(name, OBJPROP_COLOR, clr); Print(trial, "-SetColor: ", ErrorDescription(GetLastError())); ObjectSet(name, OBJPROP_XDISTANCE, xDist); Print(trial, "-SetX: ", ErrorDescription(GetLastError())); ObjectSet(name, OBJPROP_YDISTANCE, yDist); Print(trial, "-SetY: ", ErrorDescription(GetLastError())); }
Raider:
Short answer: limit object names and text to a maximum of 63 characters.
This script builds off your example and shows what happens when you try to exceed 63 characters for the name or text:
Thank you, you understood well my question and gave a good answer.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi, this is my code for 2 text objects at bottom of window.The problem is that mt4 is trimming the text, ie txt_id1="aaaaaaaabbbbbbbbbcccccccccccddddddd" but in screen i only see "aaaaaaaaabbbbccc".
any help? thank you.
if (ObjectFind(txt_id1)==-1) ObjectCreate(txt_id1, OBJ_LABEL, 1,0,0);
if (ObjectFind(txt_id2)==-1) ObjectCreate(txt_id2, OBJ_LABEL, 1,0,0);ObjectSetText(txt_id1,apstr,10,"Courier New",Moccasin);
// x=570
ObjectSet(txt_id1, OBJPROP_XDISTANCE, 0);
ObjectSet(txt_id1, OBJPROP_YDISTANCE, 400);
ObjectSetText(txt_id2,apstr1,10,"Courier New",Moccasin);
ObjectSet(txt_id2, OBJPROP_XDISTANCE, 0);
ObjectSet(txt_id2, OBJPROP_YDISTANCE, 420);