fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    To Modify Label Object Text property

    Questions & Answers
    2
    2
    696
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kketzal last edited by

      Hi:

      I want to modify the text property of a Label Object with a Variable value computed internally.

      How can I get the Label object and modify this property????

      Thanks in advance.

      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        Depends on how you want to select that object - by name or by type. If it's by type, then something like this: https://fxdreema.com/shared/NoypePCLd
        There is a little problem here, if you set "Text color" of block 3 to "No change", it actually changes it's code to None. I'm not sure when this bug appeared, because I think it worked when I was building this block, but in the new MT4 color constants are now different so I must fix them anyway. Better set the color to something. And notice that there are some labels generated by the EA itself.

        By name... it seems that I didn't created a block to select an object by name 🙂 Here is what I can suggest now - MQL code:

        string label_name="mylabel";
        string label_text="New Text";
        	
        if(ObjectFind(0,label_name)==0)
        {
            ObjectSetString(0,label_name,(ENUM_OBJECT_PROPERTY_STRING)OBJPROP_TEXT,label_text);
            ChartRedraw(0);                                      
        }
        

        The (ENUM_OBJECT_PROPERTY_STRING) is not mandatory, but I found that sometimes it reports weird error message if it's not there.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post

        Online Users

        W
        R
        R
        Y
        A

        13
        Online

        146.7k
        Users

        22.4k
        Topics

        122.6k
        Posts

        Powered by NodeBB Forums | Contributors