Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reading property of a drawing object

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

    Reading property of a drawing object

    Hi guys!

    I have a strategy that creates an unlocked HorizontalLine like this
    Code:
    myLine = Draw.HorizontalLine(this, "myLine", fillPrice, true, "");
    myLine.Stroke = new Stroke(Brushes.DarkRed, DashStyleHelper.Dot, 2);
    myLine.IsLocked = false;
    I can move myLine on the chart, but I don't know how to read its Y property in the onBarUpdate() section. It must be a basic C# thing I guess, couldn't find it anyhwere. Can anybody help please? Thanks!

    #2
    Hello RT001,

    Thank you for your post. You can retrieve the Y Value of the line using the following:

    Code:
    myLine.StartAnchor.Price
    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Thank you!

      Comment


        #4
        Hi again Kate,

        a couple of things changed in my ninjascript, and I need to update the myLine.StartAnchor.Price with a new price at each onBarUpdate loop. I tried the obvious
        Code:
        myLine.StartAnchor.Price = myValue
        (and searched a while) but it doesn't work. Can you tell me what would be the proper way to set a new y value to my HorizontalLine please?

        Comment


          #5
          Hello RT001,

          Thank you for your reply.

          To update a line drawing to a new level, you can just call it again in another iteration of On Bar Update with the same tag and a new price, which will update the existing line.

          For example, the following code in OnBarUpdate will consistently update the line to the low of the most recently processed bar when run On Bar Close:

          double YPrice = Low[0];
          DrawingTools.Line myLine = Draw.HorizontalLine(this, "myLine", YPrice, true, "");
          myLine.Stroke = new Stroke(Brushes.DarkRed, DashStyleHelper.Dot, 2);
          myLine.IsLocked = false;

          You don't have to try to change the anchor price of the existing object - I was rather curious why you were needing to access the price since you were hardcoding the line value.

          Please let us know if we may be of further assistance to you.

          Comment


            #6
            Thanks again!!!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            93 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            138 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            68 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            123 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            73 views
            0 likes
            Last Post PaulMohn  
            Working...
            X