Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cast Text from DrawObjects

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Cast Text from DrawObjects

    From the Help Guide: Lets say this is in Indi_001:
    Text myText;
    protected override void OnBarUpdate()
    {
    if(CurrentBar==50) myText=Draw.Text(this,"tag","test",0,High[0]);
    if(myText !=null ) Print(myText.Anchor.DrawnOnBar);// drawn on bar 50
    }
    .. then in Indi_002 I want to retrieve that text. I can get it with a foreach loop looking at all the tags for "tag"
    But I know the tag, so I try to read it directly with DrawObjects["tag"] and I can get it semi OK
    It shows me the Tag.
    But when I try to show DisplayName I get all sorts of errors for bad cast etc. Ive tried all sorts of combinations to get this, and even one that looks right and compiles. But it gives a run-time error of no instance assigned etc.
    I need to see DrawObjects["tag"].DisplayName and then Time.
    "missing a using or cast.??.."
    Last edited by kenz987; 04-11-2025, 11:30 AM.

    #2
    Hello kenz987,

    Thank you for your post.

    If you want to get the actual text you would need to use DisplayText, not DisplayName. Please see this forum post that discusses:



    Please let us know if you have any further questions.

    Comment


      #3
      Thanks Gaby, But thats no help. I want to avoid a loop. My Count gets very large. I have the tag, how do I get the data with DrawObjects["tag"] . . ??

      Comment


        #4
        The same concept still applies, you would access it from the DrawObjects collection via the tag.



        Code:
        if (DrawObjects["someTag"] != null && DrawObjects["someTag"] is DrawingTools.Text)
        {
        DrawingTools.Text myDrawText = DrawObjects["someTag"] as DrawingTools.Text;
        Print(myDrawText.DisplayText);
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X