I have an indicator shown in a separate window and I want to place a text label in the window. The code I have is:
string name = "tradelabel";
int chart_ID = 0;
if(ObjectFind(0,name) != 0)
": failed to create text label! Error code = ",ErrorDescription(GetLastError()));
//--- set label coordinates
//--- set the chart's corner, relative to which point coordinates are defined
//--- set the text
//--- display in the foreground (false) or background (true)
//--- enable (true) or disable (false) the mode of moving the label by mouse
The problem is with the string "indi_label".
I have a print statement for the string which shows as :
This is a snapshot of where the text label goes in the indicator window:
Any ideas why the string has been cut short please?
I've tried StringInit(indi_label,200,0) but this has no effect.
I think the maximum of characters should not exceed 63 characters. Similar as an object name in ObjectCreate. See the note: https://docs.mql4.com/objects/objectcreate
This is what I originally thought so I used StringInit which I have used in other EA's for strings much longer than 63 characters and this has worked fine. It does not work here!
Also the line of code I have to print the string indi_label is:
indi_label = "----- Number of data for symbol = " +(string)i + " Total data = " + (string)num_data + " Percentage = " + DoubleToStr(perc,0) + "%";
So I assign the whole string to indi_label which prints out as shown above - so the length of the string doesn't seem a problem.
OK sorry I shouldn't confuse 'Print' with a string object but I still don't know why StringInit does not work?
The problem aren't StringInit() or your string "indi_label" which contains the whole text but if you use longer string than 63 characters in the ObjectSetText() function then the function uses only 63 characters.
I ended up using two objects.