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 NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            81 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            149 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            79 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            52 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            58 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X