Download MetaTrader 5

Text ON chart

To add comments, please log in or register
Morteza Khorasani
111
Morteza Khorasani  

Hello

I‌ placed a text object on chart

B‌ut only a part of my text is shown on the chart. ‌ And it only occupies halp of the chart width.

ObjectCreate(objname3, OBJ_LABEL, 0, 0, 0);
   ObjectSet(objname3, OBJPROP_XDISTANCE, x3);
   ObjectSet(objname3, OBJPROP_YDISTANCE, y3);
   ObjectSet("ObjName", OBJPROP_CORNER, 0);
   ObjectSetText(objname3,"Running on wrong account. This Expert is only valid for Real account number: "+Demo1, 15, "Arial", clrDeepSkyBlue);


‌I have on the chart:

Running on wrong account. This Expert is only valid for Real ac

a‌nd the rest is not printed.

Keith Watford
Moderator
10645
Keith Watford  
I'm not sure what the limit is, but you can only use so many characters
Fernando Carreiro
2911
Fernando Carreiro  
Morteza Khorasani: I‌ placed a text object on chart ... a‌nd the rest is not printed.

As @Keith Watford stated, there is a limit of 63 Characters (see following forum topic):

Forum on trading, automated trading systems and testing trading strategies

text objects has any limit size?

raider, 2009.05.02 18:01

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()));
   }
Morteza Khorasani
111
Morteza Khorasani  
Fernando Carreiro:

As @Keith Watford stated, there is a limit of 63 Characters (see following forum topic):


Thank you
To add comments, please log in or register